rename folder based on contents

October 18, 2009 at 13:05:28
Specs: Windows xp
hello

i need a way to rename a bunch of folders ( with a .mkv) into the filename of the mkv.

after that the folder needs to be copied to g:\movies

So theres a folder named 85664820 with a file named batman 2009.mkv.

The folder must be renamed to batman 2009 and then moved to g:\downloads.

i am new to scripting, can anyone help me?

I have python installed, can also be batch.

Thnx.


See More: rename folder based on contents

Report •


#1
October 19, 2009 at 11:47:47
Well, if no one else is going to take a crack at it . . .
for /f "delims=" %%a in ('dir /b/s *.mkv') do move "%%~Fa\.." "G:\movies\%%~Na"


Report •

#2
November 17, 2009 at 12:38:55
Hi Razor2.3,
this works fine in xp but does not in windows7 64bit. Can you explain how I do that. I am a complete beginner with respect to scripting. To get it to work in xp I saved the line as a bat file and ran it. When I tried it in windows7 I get the following message
"The syntax of the command is incorrect"

Thanks


Report •

#3
November 18, 2009 at 06:49:46
Are you using it at the prompt or in a script?


=====================================
Helping others achieve escape felicity

M2


Report •

Related Solutions

#4
November 18, 2009 at 14:26:24
Hi M2
when run at the prompt I get the following error message

%%a was unexpected at this time.

How do you run it as a script?


Report •

#5
November 18, 2009 at 14:55:03
Paste it into a text file and call it MY.BAT for instance.


=====================================
Helping others achieve escape felicity

M2


Report •

#6
November 19, 2009 at 04:27:42
Hi M2,
tried both methods (from prompt and as a bat file) as detailed above:- does not work!

Report •

#7
November 19, 2009 at 05:24:08
I'd have to see what you were doing; it works fine on my copy of Win7 x64.

Report •

#8
November 19, 2009 at 05:27:26
@echo off & setLocal EnableDELAYedExpansion

for /f "tokens=* delims= " %%a in ('dir/b/s *.mkv') do (
move "%%~Fa" "G:\movies\%%~Na"
)


=====================================
Helping others achieve escape felicity

M2


Report •

#9
November 24, 2009 at 09:26:37
Thanks M2 the following worked well
@echo off & setLocal EnableDELAYedExpansion

for /f "tokens=* delims=" %%a in ('dir/b/s *.ts') do (
move "%%~Fa\.." "D:\MyMovies-HD\%%~Na"
)


Report •


Ask Question