Page 1 of 1
renaming fails
Posted: 09 Feb 2011 09:56
by maclovin
Hi there!
I need to move my randomized files to another directory. Can anyone help me with the right amount of code to accomplish this?
What I have is this:
REM MOVE TO THE RIGHT DIRECTORY
pushd %tmpDir%
setlocal EnableDelayedExpansion
for /f %%T in ('dir/s/b/a-d *.*') do (
ren "%%T" "!random!%%~nT.kvi" )
move %tmpDir%\*kvi "T:\Program\renamedFiles"
But I can't seem to get this to work, and I am fresh out of ideas
Re: renaming fails
Posted: 09 Feb 2011 11:06
by avery_larry
t:\program\renamedfiles must exist.
probably want to use *.kvi since it's an extension
path probably should be in quotes:
move "%tmpdir%\*.kvi" "t:\program\renamedfiles"
Re: renaming fails
Posted: 10 Feb 2011 01:18
by maclovin
It is not allowed to use quotes around destination.
Re: renaming fails
Posted: 10 Feb 2011 12:07
by aGerman
maclovin wrote:It is not allowed to use quotes around destination.
Why not?
What error message did your batch file display?
Regards
aGerman
Re: renaming fails
Posted: 11 Feb 2011 06:32
by maclovin
Thanks for the reply! and the kind help so far.
When I run this ( i have 2 files which I want to rename) :
REM %tmpDir% is defined in end of script
pushd %tmpDir%
setlocal EnableDelayedExpansion
For /F "Tokens=* Delims=" %%T in ('dir/s/b/a-d *.*') do (
ren "%%T" "!random!%%~nT.kvi" )
pause
move "%tmpDir%\*kvi" "C:\renamedFiles"
pause
I get this:
C:\>pushd "C:\temp"
C:\temp>setlocal EnableDelayedExpansion
C:\temp>For /F "Tokens=* Delims=" %T in ('dir/s/b/a-d *.*') do (ren "%T" "!random!%~nT.kvi" )
C:\temp>(ren "C:\temp\22022testret2.kvi" "!random!22022testret2.kvi" )
C:\temp>(ren "C:\temp\testret" "!random!testret.kvi" )
C:\temp>pause
Trykk en tast for å fortsette...
C:\temp>move " "C:\temp"\*kvi" "C:\renamedFiles"
Filename, foldername or volumname syntax is wrong
C:\temp>pause
press to continue
Re: renaming fails
Posted: 11 Feb 2011 06:55
by jeb
Ok, a really hard problem
Code: Select all
C:\temp>move " "C:\temp"\*kvi" "C:\renamedFiles"
Filename, foldername or volumname syntax is wrong
But wait ... I count 6 quotes, I expected only 4.
jeb
Re: renaming fails
Posted: 11 Feb 2011 08:05
by aGerman
Yes, jeb is absolutely right.
Probably you have a line like this:
but you should try
Regards
aGerman
Re: renaming fails
Posted: 11 Feb 2011 12:03
by maclovin
Thanks alot man! Looks like I might set this in production after all
Have a nice weekend everyone!
Re: renaming fails
Posted: 14 Feb 2011 01:42
by maclovin
What I ended up using is this:
pushd %tmpDir%
setlocal EnableDelayedExpansion
For /F "Tokens=* Delims=" %%T in ('dir/s/b/a-d *.*') do (
ren "%%T" "!random!%%~nT.kvi" )
pause
move %tmpDir%\*kvi "C:\renamedFiles\"
pause
The only difference between the working code on friday is C:\renamedFiles vs "C:\renamedFiles\"
And oh, of course, my declaration is not set tmp = "\\server\ohshitspaces" but set tmp="\\server\looknospaces"
Looks like it might be working. In production tomorrow