Batch moving files to another folder/directory in Windows?
The Question: I am getting an error message to the effect of unable to move files to a single
file. I am not trying to do this. What I am trying to do is move files from one
folder to another folder (staging) and then deleting the original folder.
If you can show me a better way to do this since I am not doing this correctly.
Here is my .cmd file:
Y:
move "Y:\ABC_files\*.js" "C:\Documents and
Settings\user\Desktop\ABC_Stage\ABC_files\"
move "Y:\ABC_files\*.CSS" "C:\Documents and
Settings\user\Desktop\ABC_Stage\ABC_files\"
move "Y:\ABC_files\*.png" "C:\Documents and
Settings\user\Desktop\ABC_Stage\ABC_files\"
move "Y:\ABC_files\*.htm" "C:\Documents and
Settings\user\Desktop\ABC_Stage\ABC_files\"
move "Y:\ABC_files\*.gif" "C:\Documents and
Settings\user\Desktop\ABC_Stage\ABC_files\"
move "Y:\ABC.htm "C:\Documents and Settings\user\Desktop\ABC_Stage\"
rmdir "Y:\ABC_files"
C:\"Program Files"\"App X"\App-IDE.exe -r ABC4.run
Solutions: Please watch the whole video to see all solutions, in order of how many people found them helpful
== This solution helped 5 people ==
Personally, I would prefer XCOPY here since it has more options that may be
useful, especially if you change the batch file, and then remove the old
directory and files using a switch.
I would also dump the quotes unless there is an actual space in the file
location or name. In your last move, you actually dropped a quote, and that
would probably produce an error. Your last statement is also incorrect: You
only put the quotes around the WHOLE command before switches, not portions of
it. I added the switches I consider potentially useful: You can see what each
does by doing an xcopy /? at a command prompt. I would also question whether
your, in your last copy, if abc.htm is really in the root directory...check
that, and edit accordingly, if necessary. Lastly, make sure you edit the user
portion to reflect your username. I don't know anything more about your last
line since that is application-specific.
Y:
xcopy Y:ABC_files*.js "C:Documents and SettingsuserDesktopABC_StageABC_files"
xcopy Y:ABC_files*.css "C:Documents and SettingsuserDesktopABC_StageABC_files"
xcopy Y:ABC_files*.png "C:Documents and SettingsuserDesktopABC_StageABC_files"
xcopy Y:ABC_files*.htm "C:Documents and SettingsuserDesktopABC_StageABC_files"
xcopy Y:ABC_files*.gif "C:Documents and SettingsuserDesktopABC_StageABC_files"
xcopy Y:ABC.htm "C:Documents and SettingsuserDesktopABC_Stage"
rd Y:ABC_files /s /q
del Y:ABC.htm
"C:Program FilesApp XApp-IDE.exe" -r ABC4.run
With thanks & praise to God, and with thanks to the many people who have made this project possible! | Content (except music & images) licensed under cc by-sa 3.0 | Music:
https://www.bensound.com/royalty-free-music | Images:
https://stocksnap.io/license & others | With thanks to user user1992594 (
https://superuser.com/users/222572), user slhck (
https://superuser.com/users/48078), user Simon (
https://superuser.com/users/208234), user KCotreau (
https://superuser.com/users/83981), user jdamae (
https://superuser.com/users/67754), user James Mertz (
https://superuser.com/users/47225), user Gary (
https://superuser.com/users/79893), user BillP3rd (
https://superuser.com/users/43972), and the Stack Exchange Network (
http://superuser.com/questions/300380). Trademarks are property of their respective owners. Disclaimer: All information is provided "AS IS" without warranty of any kind. You are responsible for your own actions. Please contact me if anything is amiss at Roel D.OT VandePaar A.T gmail.com.
Тэги:
#windows #command_line #batch_file #question #answer #shell