1.

Solve : Move syntax help (batch file)?

Answer»

hi i'm creating a batch file where i wanted to move all html FILES into another folder and then delete it, however i'm having problem with the move syntax. please tell me how to fix it. below is the code, thanks

echo off
Move /y C:\Program Files\2BrightSparks\SyncBack\*.html C:\delete
del /Q c:\delete\*.* Move "C:\Program Files\2BrightSparks\SyncBack\*.html"  "C:\delete"

should work.
I don't know the /y switch.

Why do you move the files before you delete them?

HOPE it helps
uliwell when i use your method, it give me path not found.....

anyway, the reason that i move the file before i delete it, is because its a safe guard, the same folder contain the html files contain the some exe and sys file and those can not be delete.

i'm not confided in my bath file so thats why i have those file move, before i delete it.

anyway, i found out that there is a space in Program Files, so i PUT Program%20Files instead, it still give me invalid syntax, if i remove the space, it give me path not found.When moving files, they must be moved to an existing directory. I would use a name other than delete, perhaps something like deltemp.

md deltemp
move \ c:\deltemp
cd\deltemp
del *.*

If you leave the md command in the batch file, you should also remove the temporary directory by inserting rd deltemp as the last line. By doing this, each time you run the batch file the temorary directory will recreated, the files moved and deleted, and the temporary directory removed.If you wish to err on the side of caution:

md c:\deltemp
move
If exist c:\deltemp\ del c:\deltemp\
rd c:\deltemp

If the directory is not empty you will get an error message stating so; OTHERWISE, the directory will be removed. Quote

hi i'm creating a batch file where i wanted to move all html files into another folder and then delete it, however i'm having problem with the move syntax. please tell me how to fix it. below is the code, thanks

echo off
Move /y C:\Program Files\2BrightSparks\SyncBack\*.html C:\delete
del /Q c:\delete\*.*

first, create c:\delete with
md c:\delete
then write
move "C:\Program Files\2BrightSparks\SyncBack\*.html" c:\delete
that is, with the " signs
and afaik this should be it  guys i already try

Move /y "C:\Program Files\2BrightSparks\SyncBack\*.html" "C:\delete"

and

Move /y "C:\Program Files\2BrightSparks\SyncBack\*.html" C:\delete

none of them works, and i already have a folder name delete in my C drive.For what do you need the /y switch?

uliThe /Y switch silences the prompt from displaying "Moving XYZ.ABC" on the screen, thus making the file run more clearly. However, this is a disaster in testing mode.

Try the command without the /Y switch. Then check the C:\delete directory to ensure that the file is there. Report back on what happens, along with any error messages.

Tip #1 of batch files: Make it work, then worry about hiding the behind-the-scenes details. well ...

when i use these [Move "C:\Program%20Files\2BrightSparks\SyncBack\*.html" C:\delete] syntax it give me the error [The system cannot find the path specified.]

when i use these [Move "C:\Program%20Files\2BrightSparks\SyncBack\*.html" "C:\delete"] syntax it give me the error [THe system cannot find the path specified]

when i use these [Move C:\Program%20Files\2BrightSparks\SyncBack\*.html C:\delete] syntax it give me the error [Invalid Syntax]"C:\Program Files\2BrightSparks\SyncBack\*.html"
Why are you inserting %20? Your browser will understand that. Dos will think its part of the directory name. If it doesn't work as typed above, try changing to the CONTAINING directory before invoking the move command. Quote
"C:\Program Files\2BrightSparks\SyncBack\*.html"
Why are you inserting %20? Your browser will understand that. Dos will think its part of the directory name. If it doesn't work as typed above, try changing to the containing directory before invoking the move command.

yes, what has the %20 (space) syntax to do with that ?
Imho you just go

move "C:\Program Files\2BrightSparks\SyncBack\*.html" c:\delete

since no quote marks are necessary around delete
and if the delete dir exists,
either your path isn't quite right, or
there really are no html files in C:\Program Files\2BrightSparks\SyncBack\
to move yet


Discussion

No Comment Found