How do I move my renamed files?

February 9, 2011 at 07:49:44
Specs: Win server 2k3, 1GB
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


See More: How do I move my renamed files?

Report •

#1
February 9, 2011 at 12:33:40
what is the error messege you are getting..
run the code with out @echo off and then psate the output

Subhash Chandra.
www.s-chandra.co.cc


Report •

#2
February 9, 2011 at 23:03:32
The error reply is that I can't find any files to rename.


Report •

#3
February 10, 2011 at 10:31:18
if you paste the exact output with error it will make more sense ..
run the code with out @echo off and then psate the output

Subhash Chandra.
www.s-chandra.co.cc


Report •

Related Solutions

#4
February 11, 2011 at 04:32:15
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


Report •

#5
February 11, 2011 at 11:00:46
Hi

Im not that good with batch programming but im learning it.

I dont know if your way of doing it is viable but i learned something else. Lets say that you have a *.doc file in your root folder. the code would then be:
cd\
ren 22022testret2.kvi %random%.kvi

you used "!" and I used "%" dont know if that makes a difference.

Actually I have just tested it and it appears if you want to give your *.kvi file name the name of !random! then you use !random! . if you want to give it a random file name you should use %random%


Report •

#6
February 11, 2011 at 11:12:26
lol I understand exactly what the problem is..
move "%tmpDir%\*kvi" "C:\renamedFiles" should be
move "%tmpDir%\*kvi" "C:\renamedFiles\" :)
all that should be added here is the "\" symbol i had the same problem with one of my batch files :)

Report •

#7
February 12, 2011 at 07:55:22
C:\temp>move " "C:\temp"\*kvi" "C:\renamedFiles"
Filename, foldername or volumname syntax is wrong

after move there is 2 quotes.. remove one of them and add \ as suggested by D_Pikster .
" "C:\temp"\*kvi

Subhash Chandra.
www.s-chandra.co.cc


Report •

#8
February 13, 2011 at 23:32:28
hi goodfolks!

Thanks for the response! I have changed some of the declaration, so I don't get the spaces.

I really don't want the spaces :-)

What I ended up with, and it looks like it's working 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

(What's the difference between C:\renamedFiles and "C:\renamedFiles\" with a slash in the end?)


Thanks alot for your kind cooperation and help!

Maclovin!


Report •

#9
February 13, 2011 at 23:38:34
What I ended up with 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


Report •

#10
February 13, 2011 at 23:53:42
move command will not work with C:\renamedFiles without a slash

Subhash Chandra.
www.s-chandra.co.cc


Report •

Ask Question