X-Authentication-Warning: delorie.com: mailnull set sender to opendos-bounces using -f Message-ID: <003701c18812$8f19b4e0$c03dfea9@atlantis> From: "Matthias Paul" To: References: <3C1C6E72 DOT 2090502 AT drdos DOT org> Subject: Re: [OT] ren Date: Tue, 18 Dec 2001 23:19:28 +0100 Organization: University of Technology, RWTH Aachen, Germany MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id fBIMMer15608 Reply-To: opendos AT delorie DOT com On 2001-12-16, Florian Xaver wrote: > I would need a rename program which: > > - supports lfn (i use lfndos) > - can rename a file list: e.g. ren *.mp3 "temp-*.mp3" > - Mabe can do this also in subdirectories While the above proposed syntax probably wonīt give you the expected results but instead will overwrite the first few characters of the destination files with "temp-" instead of pre-pending it to the filename, you can do this with 4DOS (http://www.jpsoft.com). Assuming that you donīt want to rename files which are already named "temp-*.mp3" to "temp-temp-*.mp3", the following should work (untested): FOR /[!temp-*] %%x IN ("*.mp3") DO REN "%%x" "temp-%%x" (If you donīt want to use 4DOS) you should be able to use MS-DOS 7.0+ COMMAND.COM for this as well: IF EXIST tmpdir\nul GOTO error MD tmpdir FOR %%x IN (*.mp3) DO REN %%x .\tmpdir\temp-%%x REN .\tmpdir\*.* . RD tmpdir :error Unfortunately, this will not work as expected under DR-DOS 7.02+ COMMAND.COM, because DR-DOS COMMAND.COM does not support the LFNFOR command yet. So, it will prepend the filenames in the destination with "temp-", however, it will usually apply this to the short filenames, not the long ones... It would work reliable if you were using short filenames, only. Under MS-DOS 7.0+ COMMAND.COM and 4DOS 7.0+ you should be able to control the behaviour of the FOR command with the LFNFOR command. Welcome to the odd world of Microsoft VFAT LFN design implications... The advantage of the second approach is that this will also work reliable for files which already match "temp-*.mp3" on entry. And by moving the files to a different directory you can be sure that you wonīt enter any infinite loops. The disadvantage is that you must have user rights to create and delete a directory on the current volume, which, however, shouldnīt be an issue unless youīre in a network. Greetings, Matthias -- ; http://www.uni-bonn.de/~uzs180/mpdokeng.html; http://mpaul.drdos.org