Discussion:
Copy folder contents and change extensions
(too old to reply)
Terry Pinnell
2021-10-25 09:07:58 UTC
Permalink
On this Win 10 PC I can use my backup application (SecondCopy) to copy a folder
and its entire contents. But all the source files have the extension '.ino' and
I want that changed to '.txt' for the copies, which SecondCopy cannot achieve.
(That will allow me to view them on my iPad with Dropbox, which cannot do so
despite their being plain text files.)

Is it possible with a batch file please and if so I'd greatly appreciate a
suggested file I can try please?

Terry
Zaidy036
2021-10-25 14:39:29 UTC
Permalink
Post by Terry Pinnell
On this Win 10 PC I can use my backup application (SecondCopy) to copy a folder
and its entire contents. But all the source files have the extension '.ino' and
I want that changed to '.txt' for the copies, which SecondCopy cannot achieve.
(That will allow me to view them on my iPad with Dropbox, which cannot do so
despite their being plain text files.)
Is it possible with a batch file please and if so I'd greatly appreciate a
suggested file I can try please?
Terry
I believe you can make a new folder if it does not exist already and
then use COPY and change the name at the same time. If there is a
problem do the copy without a name change and use RENAME.

IF NOT EXIST <new path> MKDIR <new path>
COPY /Y <old path>\*.ino <new path>\*.txt
-or-
COPY /Y <old path>\*.ino <new path>
REN <new path>\*.ino *.txt
Terry Pinnell
2021-10-26 08:54:24 UTC
Permalink
Post by Zaidy036
Post by Terry Pinnell
On this Win 10 PC I can use my backup application (SecondCopy) to copy a folder
and its entire contents. But all the source files have the extension '.ino' and
I want that changed to '.txt' for the copies, which SecondCopy cannot achieve.
(That will allow me to view them on my iPad with Dropbox, which cannot do so
despite their being plain text files.)
Is it possible with a batch file please and if so I'd greatly appreciate a
suggested file I can try please?
Terry
I believe you can make a new folder if it does not exist already and
then use COPY and change the name at the same time. If there is a
problem do the copy without a name change and use RENAME.
IF NOT EXIST <new path> MKDIR <new path>
COPY /Y <old path>\*.ino <new path>\*.txt
-or-
COPY /Y <old path>\*.ino <new path>
REN <new path>\*.ino *.txt
Thanks, I'll try that shortly. But are you fairly sure it will act recursively
on the files in all subfolders?

I also looked at using the command prompt RENAME (after the successful copy),
but cannot get my head around making it work on all subfolders.

Terry
Zaidy036
2021-10-26 15:46:43 UTC
Permalink
Post by Terry Pinnell
Post by Zaidy036
Post by Terry Pinnell
On this Win 10 PC I can use my backup application (SecondCopy) to copy a folder
and its entire contents. But all the source files have the extension '.ino' and
I want that changed to '.txt' for the copies, which SecondCopy cannot achieve.
(That will allow me to view them on my iPad with Dropbox, which cannot do so
despite their being plain text files.)
Is it possible with a batch file please and if so I'd greatly appreciate a
suggested file I can try please?
Terry
I believe you can make a new folder if it does not exist already and
then use COPY and change the name at the same time. If there is a
problem do the copy without a name change and use RENAME.
IF NOT EXIST <new path> MKDIR <new path>
COPY /Y <old path>\*.ino <new path>\*.txt
-or-
COPY /Y <old path>\*.ino <new path>
REN <new path>\*.ino *.txt
Thanks, I'll try that shortly. But are you fairly sure it will act recursively
on the files in all subfolders?
I also looked at using the command prompt RENAME (after the successful copy),
but cannot get my head around making it work on all subfolders.
Terry
FORFILES does recursive using /S

Loading...