Hi all,
I need to open up a file and then save it in a different format.i.e.
Open C:\Book1.err
Save as C:\Book1.txt
Close
I will have many files, with varaiable names, but always ending '.err'
Once opened and saved, I would also like to move the original file to a new location (to prevent duplication of the save as).
C:\Loaded\Book1.err
Is it possible to do this via a .bat file? If so, with what code?
Many thanks
Open file and save in different format
Moderator: DosItHelp
Re: Open file and save in different format
I'd like to clarify the task:
1) Are these .err files in a single directory?
2) Do you want each .err file to be duplicated, and be given a .txt extension?
3) if the .err files are in subdirectories, what do you need to do if two .err files have the same name?
1) Are these .err files in a single directory?
2) Do you want each .err file to be duplicated, and be given a .txt extension?
3) if the .err files are in subdirectories, what do you need to do if two .err files have the same name?
-
- Posts: 4
- Joined: 19 Sep 2012 08:02
Re: Open file and save in different format
Hi,
Thanks for the quick reply.
1) Yes
2) Yes - the .txt file to remain in the original directory, the old .err file to be moved to the new subdirectory
3) There will never be duplicate names, the files are sequentially named, to prevent duplication
Thanks
Thanks for the quick reply.
1) Yes
2) Yes - the .txt file to remain in the original directory, the old .err file to be moved to the new subdirectory
3) There will never be duplicate names, the files are sequentially named, to prevent duplication
Thanks
Re: Open file and save in different format
This is untested so test it in a dummy folder with dummy files first.
Code: Select all
@echo off
for %%a in (*.err) do (
copy /b "%%a" "c:\loaded" >nul
ren "%%a" "%%~na.txt"
)
-
- Posts: 4
- Joined: 19 Sep 2012 08:02
Re: Open file and save in different format
Hi,
Nearly there!
This has changed the files from .err to .txt (great!!), but I no longer have the original .err files
(it has not copied, it has just renamed)
I want to save a copy of the originals to the C:\Loaded file and leave the new .txt files in C:\
Thanks
Nearly there!
This has changed the files from .err to .txt (great!!), but I no longer have the original .err files
(it has not copied, it has just renamed)
I want to save a copy of the originals to the C:\Loaded file and leave the new .txt files in C:\
Thanks
Re: Open file and save in different format
Does c:\loaded actually exist yet? Create the folder and it will copy them.
-
- Posts: 4
- Joined: 19 Sep 2012 08:02
Re: Open file and save in different format
You are a hero!!
Thanks for your help!!
Thanks for your help!!