Bulk copying of text files, but with new extension

Page 1 of 2 12 LastLast

  1. Posts : 478
    Windows 10
       #1

    Bulk copying of text files, but with new extension


    I have several hundred text files with the extension '.ino'. On my Win 10 PC I can view them in any text editor. They are also accessible on my iPad because they are in subfolders of my Dropbox folder. However they cannot be viewed directly on the iPad. One of several frustrations I have with either iOS or Dropbox - haven't quite pinned the culprit down in this case.

    Could some kind expert please suggest a batch file, script or any tool that would take a parent folder (File Explorer) path as its input, and make identically named copies of every .ino file in every subfolder of it, but with a .txt extension, saving them in the same location. And over-writing on any subsequent occasions.

    So files like this
    C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\My Sketches\MY SKETCHES 2021-2022\DFR SD ORIG type\JUKEBOX\J26Sh9plus\J26Sh9plus.ino

    would be accompanied by
    C:\Users\terry\Dropbox\Electronics\Arduino\SKETCHES\My Sketches\MY SKETCHES 2021-2022\DFR SD ORIG type\JUKEBOX\J26Sh9plus\J26Sh9plus.txt

    If this was a one-off task I would tackle it within File Explorer. I did so a year ago and it was tedious. But I will want to update it at intervals, hence the need for some neat automation please.

    Any help would be much appreciated.

    Version 21H2 (OS Build 19044.2604)
      My Computer


  2. Posts : 6,345
    Windows 11 Pro - Windows 7 HP - Lubuntu
       #2

    That is quite easy.
    @Matthew Wai or @Paul Black are very good on batch files and can help you. Wait for them.
    Last edited by Megahertz; 20 Feb 2023 at 18:27.
      My Computers


  3. Posts : 478
    Windows 10
    Thread Starter
       #3

    Megahertz said:
    That is quite easy.
    @Matthew Wai or @Paul Black are very good on batch files and can help you. Wait for them.
    Thanks, that’s good news. I have just received a PM from das10 but darned if I can find a Reply button anywhere on that cluttered PM page ;-) If I don’t succeed, many thanks and I will try that batch tomorrow morning.
    Terry.
      My Computer


  4. Posts : 6,345
    Windows 11 Pro - Windows 7 HP - Lubuntu
       #4

    Place the batch.cmd.txt on the folder you have the ino files.
    Rename batch.cmd.txt to batch.cmd
    Execute batch.cmd
    batch.cmd.txt
      My Computers


  5. Posts : 18,044
    Win 10 Pro 64-bit v1909 - Build 18363 Custom ISO Install
       #5

    Hello @Terrypin,

    Terrypin said:
    Could some kind expert please suggest a batch file, script or any tool that would take a parent folder (File Explorer) path as its input, and make identically named copies of every .ino file in every subfolder of it, but with a .txt extension, saving them in the same location. And over-writing on any subsequent occasions.

    If this was a one-off task I would tackle it within File Explorer. I did so a year ago and it was tedious. But I will want to update it at intervals, hence the need for some neat automation please.
    Yes, a .bat, .cmd, or .ps1 script could do this for you, but as this sounds like it will be an ongoing process, you will probably be better off using a ready made utility. This will save you keep changing the script for new locations, folder names, extensions, etc.

    Maybe something like Bulk Rename Utility or similar. Or, for MANY choices 53 Best Free File Rename Software.

    I hope this helps.
      My Computer


  6. Posts : 2,917
    Windows 10 Pro for the Bro
       #6

    Hi Terry. I use a very useful tool called: Better File Rename

    Here's an example of how to do the task you want. But first, make a backup copy of the original folder, and place it somewhere. And with the new copy of the folder with all the ino files, we will change them so they have a ".txt" extension instead of the ".ino" extension:

    (click on the picture, and check out the right side of how the files would have the txt extension instead of ino extension.)

    Bulk copying of text files, but with new extension-image.png
      My Computer


  7. Posts : 181
    10, server 2016, server2012
       #7

    wouldnt BRU software be a better fit for this? unless theres other features that exist in better file rename that BRU doesn't have which im not aware of.

    BRU = batch rename utility, look it up.
      My Computer


  8. Posts : 478
    Windows 10
    Thread Starter
       #8

    Thanks to all, much appreciate those responses.

    As per my post last night, before coming back here I sepent an hour or so methodically testing the BAT that @das10 sent me. Delighted to report that it works perfectly! Please confirm you see this, das10, as I found my last visit to the PM page a challenge!
    I'll paste the BAT below:

    Code:
    @echo off
    
    echo.
    echo. Duplicate all .ino files as .txt files in a given Folder 
    echo. (overwrite old duplicated .txt files if they exist).
    echo.
    echo. Enter the Full Path of the Main Folder at the prompt below:
    echo.
    
    set /P fold=
    set fold=%fold:""=%
    set fold=%fold:"=%
    cd /D %fold%
    for /f "delims=" %%A in ('dir /s /b /a-d "%fold%\*.ino"') do (echo.copy /Y "%%~dpnxA" "%%~dpnA.txt" & copy /Y "%%~dpnxA" "%%~dpnA.txt")
    pause
    exit
    I plan to try the other suggestions too when I finish the current project. Starting with BRU which I've used for many years. Didn't occur to me that it might be up to the job, given that I want to add files rather than just rename them, so looking forward to exploring that in a day or two.

    Right now I'm preparing to launch the BAT on my 260 MB parent folder containing 24,000 files in 18,000 folders!
      My Computer


  9. Posts : 3,275
    Win10
       #9

    Yes, I see it. Hopefully it shows you one avenue to explore in your quest.
      My Computers


  10. Posts : 6,345
    Windows 11 Pro - Windows 7 HP - Lubuntu
       #10

    The batch file I posted has one line and does the job
    Code:
    copy *.ino *.txt
      My Computers


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 13:27.
Find Us




Windows 10 Forums