Batch Script to Replace Filenames with Increasing Numbers to be Reverted Later

50 views Asked by At

I am attempting to write a series of scripts to copy a folder full of non-predetermined files and possibly subdirectories from a Windows 7/10 environment to a MS-DOS 7.0 environment (that's Windows 95 in DOS-Mode) running in Vanilla DOSBox 0.74-3. The copy process, which cannot be worked around or changed, destroys long file names. The software on the MS-DOS 7.0 end requires these long file names to run properly.

My plan is to have a Windows batch script with a simple dir /b /on /s > lfn.txt to keep track of all the long file names.

Then next step ideally, and here is where I am stumped, reads back through the lfn.txt and renames all the files from top to bottom to an increasing integer starting at 1 and never resetting. My goal is to be able to copy and tweak this script to work on MS-DOS where it does the reverse. If the solution, even conceptually, can be made that portable I would prefer that solution even if it is more verbose or inefficient.

I apologize if this has been asked and answered elsewhere. If it has please link to it before closing this thread.

0

There are 0 answers