FAQ  •  Registrieren  •  Anmelden

Renaming multiple files using batch file

Moderator: Spambusters

<<

fibre_on

Beitrag Mi 1. Feb 2012, 13:38

Renaming multiple files using batch file

Hi guys,
I'm working on a batch file for quite a while now but I can't solve a problem.
I'm working on a Windows Vista system and I created a *.cmd file using the Windows Editor.

Description of my task:
Within the script I ask the user to input several variables, i.e. "VORJAHR" (i.e. 2011), "VORMONAT" (i.e. 12), "JAHR" (i.e. (2012). "MONAT" (i.e. 01).
I do then take those variables to search for files in several folders and subfolders (which is the variable "VORLAGENORDNER") having used "VORJAHR_VORMONAT" within their filenames. The filenames are structured either ABCDEFG_2011_12.doc or ABCDEFG_2011_12_en.doc, while "ABCDEFG" is not defined in length or structure.
Now, I want to replace the variables "VORJAHR_VORMONAT" (i.e. 2011_12) with "JAHR_MONAT" (i.e. 2012_01).
In other words the target files should be renamed from ABCDEFG_2011_12.doc to ABCDEFG_2012_01.doc.

My command line so far:
forfiles /p %VORLAGENORDNER% /m *%VORJAHR_VORMONAT%* /s /C "cmd /c ren @file *%JAHR_MONAT%*"

What do I do wrong?
I hope that someone can help me on that account.

Thanks in advance!
fibre
<<

CptKlotz

Benutzeravatar

Site Admin

Beiträge: 2140

Registriert: Di 8. Mär 2005, 00:36

Wohnort: Dorsten

Beitrag Do 2. Feb 2012, 00:56

Re: Renaming multiple files using batch file

Hello,

Windows (and its command line or "DOS mode") are not the focus of this forum.

Also, since you're obviously working with German data and are quite probably posting from the network of a well-known German company, is there a special reason you're posting this in the English section of a German hobbyist forum of all places?

Using a foreign language does not make this a free support forum for companies.

Maybe you can recommend to me a web forum where I'll get a free train ride.

Otherwise, if you're in need of IT consulting or tech support, please hire a professional!

[Thread closed]
“It is impossible to defeat an ignorant man in argument.” (William G. McAdoo)

Zurück zu English Board

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.
Deutsche Übersetzung durch phpBB.de