Back to home page

DOS ain't dead

Forum index page

Log in | Register

Back to the forum
Board view  Mix view

Batch program for natural to 7-digit file name conversion? (Miscellaneous)

posted by tom(R) Homepage, Germany, 09.06.2017, 13:02

> Dear all,
>
> I need to transfer data between different programs. However, the names
> of the files with the respective data follow different conventions:
> the input uses natural numbers for files names (i.e. 1, 2 ... 999999),
> whereas the target program requires seven-digit file names, with leading
> zeroes (0000001, 0000002 ... 0999999, 1000000) to order them properly.
>
> I wonder whether such conversion could be done with a batch program's
> "FOR %variable IN (set) DO"-loops, or if a more complex command set is
> required. Maybe with a 4DOS's .BTM batch file, or using a script
> language (Perl, Java, Rexx)?
>
> Thanks for input, Torsten

FOR %%i IN (?) DO call move.bat %%i 000000%%i
FOR %%i IN (??) DO call move.bat %%i 00000%%i
...

move.bat:
move /Y srcdir\%1 destdir
ren destdir\%1 %2

**** OR even better ******
FOR %%i IN (?) DO ren %%i 0%%i
FOR %%i IN (??) DO ren %%i 0%%i
FOR %%i IN (???) DO ren %%i 0%%i
FOR %%i IN (????) DO ren %%i 0%%i
FOR %%i IN (?????) DO ren %%i 0%%i
FOR %%i IN (??????) DO ren %%i 0%%i
FOR %%i IN (???????) DO ren %%i 0%%i

*** both methods assume there are only files to be converted in the directory

 

Complete thread:

Back to the forum
Board view  Mix view
15095 Postings in 1355 Threads, 245 registered users, 15 users online (0 registered, 15 guests)
DOS ain't dead | Admin contact
RSS Feed
powered by my little forum