Seite 1 von 1

Renaming multiple files using batch file

Verfasst: Mi 1. Feb 2012, 12:38
von fibre_on
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

Re: Renaming multiple files using batch file

Verfasst: Mi 1. Feb 2012, 23:56
von CptKlotz
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]