renaming fails
Moderator: DosItHelp
renaming fails
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
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
-
- Expert
- Posts: 391
- Joined: 19 Mar 2009 08:47
- Location: Iowa
Re: renaming fails
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"
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
It is not allowed to use quotes around destination.
Re: renaming fails
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
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
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
Ok, a really hard problem
But wait ... I count 6 quotes, I expected only 4.
jeb
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
Yes, jeb is absolutely right.
Probably you have a line like this:
but you should try
Regards
aGerman
Probably you have a line like this:
Code: Select all
set tmpDir = "C:\temp"
but you should try
Code: Select all
set "tmpDir=C:\temp"
Regards
aGerman
Re: renaming fails
Thanks alot man! Looks like I might set this in production after all
Have a nice weekend everyone!
Have a nice weekend everyone!
Re: renaming fails
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
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