Hi everyone apologies if ive posted in wrong forum but think DOS commands is what I need.
I have a folder of which is C:/Downloads of which has files and folders in it.
What im trying to do is if possible when I click on the shortcut icon on the desktop i need to create a new folder within C:/Downloads and then move all the files into that folder. There will be other folders within the folder C:/Downloads already but I just need the individual files to be moved. Once it has moved the files I need a message box or something to pop up asking me to name what the folder is going to be called and then name it.
Any ideas if this is possible.
Thanks
Can I merge files and move in a command?
Moderator: DosItHelp
Re: Can I merge files and move in a command?
There is no such thing like a message box in Batch. To help out I'll offer you a VBScript code (save with file extension .vbs)
Steffen
Code: Select all
Option Explicit
Const strDLFolder = "C:\Downloads"
Dim objFSO, objWShell, objDLFolder, strNewFolder, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWShell = CreateObject("WScript.Shell")
If Not objFSO.FolderExists(strDLFolder) Then objFSO.CreateFolder(strDLFolder)
objWShell.CurrentDirectory = strDLFolder
Set objDLFolder = objFSO.GetFolder(strDLFolder)
If objDLFolder.Files.Count = 0 Then WScript.Quit
Do
Err.Clear
strNewFolder = InputBox("Folder Name", vbLf & "Enter the name of the folder to be created:")
If strNewFolder = False Then WScript.Quit
On Error Resume Next
objFSO.CreateFolder strNewFolder
Loop While Err.Number <> 0 Or Not objFSO.FolderExists(strNewFolder)
On Error Goto 0
For Each objFile In objDLFolder.Files
objFSO.MoveFile objFile.Name, strNewFolder & "\"
Next
objWShell.Popup "All files moved.", 0, "Done", vbInformation Or vbSystemModal Or &h00040000&
Re: Can I merge files and move in a command?
Seffen
A BIG BIG Thanks.
You are a legend and saved me loads of work doing that.
A BIG BIG Thanks.
You are a legend and saved me loads of work doing that.
Re: Can I merge files and move in a command?
I forgot one thing sorry !!
The script above works perfectly but there one thing I missed off. What im trying to do is if poss when folder created and files moved I need the folder C:/Downloads to re open to show the folders and launch 7 zip file manager so I can ZIP and password protect file.
If youre not able to launch 7 zip file manager thats fine as long as I can get it to reopen C:/Downloads.
Thanks
The script above works perfectly but there one thing I missed off. What im trying to do is if poss when folder created and files moved I need the folder C:/Downloads to re open to show the folders and launch 7 zip file manager so I can ZIP and password protect file.
If youre not able to launch 7 zip file manager thats fine as long as I can get it to reopen C:/Downloads.
Thanks
Re: Can I merge files and move in a command?
Just add this line at the end of the script.
Steffen
Code: Select all
objWShell.Run "explorer.exe /select,""" & objFSO.BuildPath(strDLFolder, strNewFolder) & """"
Re: Can I merge files and move in a command?
Steffen
A big big thanks once again
A big big thanks once again
Re: Can I merge files and move in a command?
Is there anyway I can add to command below...
What it does at present is exactly what I want it to do but im trying to amend the end so that once folder created and files moved I want to have a message box or something pop up asking me if to save to section A or B and then I click on selection it moves the folder and opens it in the new section and once opened the window at the end pop up as this text
[/code]
I.E created the folder and then click on selection "A" and folder then moves to C:\DOWNLOADS\SECTIONA and then opens it and pops with with the message "ALL FILES MOVED NOW 7ZIP AND PASSWORD PROTECT FOLDER"
or if I select "B" I need it moving to C:\DOWNLOADS\SECTIONB and then opens it and pops with with the message "ALL FILES MOVED NOW 7ZIP AND PASSWORD PROTECT FOLDER"
Is this possible.
Thanks
What it does at present is exactly what I want it to do but im trying to amend the end so that once folder created and files moved I want to have a message box or something pop up asking me if to save to section A or B and then I click on selection it moves the folder and opens it in the new section and once opened the window at the end pop up as this text
Code: Select all
objWShell.Popup "ALL FILES MOVED NOW 7ZIP AND PASSWORD PROTECT FOLDER", 0, "Done", vbInformation Or vbSystemModal Or &h00040000&
I.E created the folder and then click on selection "A" and folder then moves to C:\DOWNLOADS\SECTIONA and then opens it and pops with with the message "ALL FILES MOVED NOW 7ZIP AND PASSWORD PROTECT FOLDER"
or if I select "B" I need it moving to C:\DOWNLOADS\SECTIONB and then opens it and pops with with the message "ALL FILES MOVED NOW 7ZIP AND PASSWORD PROTECT FOLDER"
Code: Select all
Option Explicit
Const strDLFolder = "C:\Downloads"
Dim objFSO, objWShell, objDLFolder, strNewFolder, objFile
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWShell = CreateObject("WScript.Shell")
If Not objFSO.FolderExists(strDLFolder) Then objFSO.CreateFolder(strDLFolder)
objWShell.CurrentDirectory = strDLFolder
Set objDLFolder = objFSO.GetFolder(strDLFolder)
If objDLFolder.Files.Count = 0 Then WScript.Quit
Do
Err.Clear
strNewFolder = InputBox("Folder Name", vbLf & "Enter the name of the folder to be created:")
If strNewFolder = False Then WScript.Quit
On Error Resume Next
objFSO.CreateFolder strNewFolder
Loop While Err.Number <> 0 Or Not objFSO.FolderExists(strNewFolder)
On Error Goto 0
For Each objFile In objDLFolder.Files
objFSO.MoveFile objFile.Name, strNewFolder & "\"
Next
objWShell.Popup "All files moved.", 0, "Done", vbInformation Or vbSystemModal Or &h00040000&
Is this possible.
Thanks