| 1. |
Solve : DOS Batch? |
|
Answer» Sorry if I seem annoying or anything... but I'm sure that Try not using quotes on the passed parameter, you're using short names anyway so they're not required. All I am doing is dragging the file I want deleted to the shortcut to the batch file, the quotes on the passed parameters is what DOS spits out as an echo to the commands in the batch file. THUS: cmd = Set newname=%RANDOM%.%RANDOM% echo = D:\Documents and Settings\user>Set newname=725.23907 cmd = ren %1 %newname% echo = C:\Documents and Settings\user>ren "C:\Documents and Settings\user\desktop\test.txt" 725.23907 cmd = DEL %~d1%~p1%newname% echo = C:\Documents and Settings\user>DEL C:\Documents and Settings\user\desktop\725.23907 The system cannot find the file specified. What's interesting is that when the REN cmd is issued the echo uses qoutes on the parameters while when the DEL cmd is issued it does not. Bones92, Quote I ran it from cmd.exe, if that makes a difference...Not sure what you mean here, does cmd.exe need to be called from within a batch file? Or ae you saying you types cmd,exe in the run field to open a DOS window? I BELIEVE the dos batch file does use cmd.exe for exicution.Well at least we're on the same page: Code: [Select]Set newname=%RANDOM%.%RANDOM% ren %1 %newname% DEL %~d1%~p1%newname% pause exit Quote All I am doing is dragging the file I want deleted to the shortcut to the batch file That information would have been helpful from the beginning especially Quote i used shout names to shorten what I had to type.Please read this. A quick FIX would be to insert the quotes regardless of short or long file names: Code: [Select]Set newname=%RANDOM%.%RANDOM% ren %1 %newname% DEL "%~d1%~p1%newname%" pause exit When Windows 3000 arrives it will probably still support batch code. OH Sweet Jesus! That's it! Can all the DOS echo responses be piped to a single txt file? For future debugging this would be helpful . Beautiful job, wish I could have saved us some time, but I am sorta new with this stuff. Thanks for your efforts Quote When Windows 3000 arrives it will probably still support batch code. Don't plan on sticking around to find out! Yeah it seems the only way it will keep a log of its self is if u put an output code (echo %whatever% >> log.txt) and if u click on batch file rather than just drag and drop, but then it only keeps a log of the click, nothing is deleted. Oh and I was wondering how to change it to where it uses the files actual name as a variable apposed to renaming it to random numbers?DragonMaster, Quote I was wondering how to change it to where it uses the files actual name as a variable apposed to renaming it to random numbers? I'm a bit perplexed as to why you would want to do that??? I think this might work though: Code: [Select]Set newname=%1 DEL %newname% exitYeah that worked lol, thanks Ionic! |
|