Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
share|improve this question
    
Can you post the error? –  MaxMackie Jun 21 '11 at 22:32
    
Heh, you could always install Cygwin, thus gain Bash and then move files with "mv". –  Doc Jun 21 '11 at 23:58
    
Are you sure that "C:\Documents and Settings\user\Desktop\ABC_Stage\ABC_files" exists? You get the error you mentioned if it does not because the command-prompt does not know that ABC_files is a directory, and thinks that you are using that as the destination filename in a move-rename operation. –  Synetech Jun 22 '11 at 3:17
    
Also, why not just use move "Y:\ABC_files\*" "...ABC_files"? You don't need to append the slash to the end of the target directory, and you cannot rd the source directory unless you move all files anyway, so there's no point in selectively moving them like that (unless you move different file types to different directories). –  Synetech Jun 26 '12 at 19:34

4 Answers 4

up vote 3 down vote accepted

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 Settings\user\Desktop\ABC_Stage\ABC_files\"
xcopy Y:\ABC_files\*.css "C:\Documents and Settings\user\Desktop\ABC_Stage\ABC_files\"
xcopy Y:\ABC_files\*.png "C:\Documents and Settings\user\Desktop\ABC_Stage\ABC_files\"
xcopy Y:\ABC_files\*.htm "C:\Documents and Settings\user\Desktop\ABC_Stage\ABC_files\"
xcopy Y:\ABC_files\*.gif "C:\Documents and Settings\user\Desktop\ABC_Stage\ABC_files\"
xcopy Y:\ABC.htm "C:\Documents and Settings\user\Desktop\ABC_Stage\"
rd Y:\ABC_files /s /q
del Y:\ABC.htm
"C:\Program Files\App X\App-IDE.exe" -r ABC4.run
share|improve this answer

There are two solutions that suggest themselves to what you want to do. If you want to copy only the .js, .css, .htm, etc. files, go with the first solution. If you really want everything in the source folders, go for the second. Note that both give you the opportunity to make sure everything's ok before deleting the source files. Also, it assumes that the target directory already exists.

Solution 1:

for %%f in (js css png htm gif) do (
copy Y:\ABC_files\*.%%f "C:\Documents and Settings\user\Desktop\ABC_Stage\ABC_files"
)

copy Y:\ABC.htm "C:\Documents and Settings\user\Desktop\ABC_Stage"

echo Check that your files copied correctly, then
pause
rmdir /s /q Y:\ABC_files
"C:\Program Files\App X\App-IDE.exe" -r ABC4.run

Solution 2:

xcopy Y:\ABC_files\*.* "C:\Documents and Settings\user\Desktop\ABC_Stage\ABC_files" /s /e

echo Check that your files copied correctly, then
pause
rmdir /s /q Y:\ABC_files
"C:\Program Files\App X\App-IDE.exe" -r ABC4.run
share|improve this answer
    
This is a good solution. I need to automate this. I tested it and its asking for prompts. How can I force this? –  jdamae Jun 22 '11 at 4:25
1  
Just remove the "echo" and "pause" statements and add "/Y" to "copy" and "xcopy" to suppress prompts. –  BillP3rd Jun 24 '11 at 19:43

Why not move the entire directory? That way you have all your files copied with one command without having to clean anything up.

Move Y:\ABC_Files "%userprofile%\desktop\staging"

Note: %userprofile% is a variable for C:\documents and settings\CurrentlyLoggedOnUser\

In batch files, type these to achieve file relocation:

Move /-y "Y:\ABC_Files" "%userprofile%\desktop\staging"
share|improve this answer

Try the following command

move "C:\Documents and Settings\amitrajk\Desktop\New Folder\*.*" "C:\Documents and Settings\amitrajk\Desktop\New Folder\InFolder"
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.