Hello everyone!
I'm new to this forum but I thank in advance anyone help me!
I am writing to ask for help, I need to create a .Bat file that performs the following tasks:
Given a specific path ( eg c:\source ) in which there is a single file A_stringSource.Txt (Example A_123456789.txt )
write in another folder ( eg c:\destination) 5 empty files .dat format name with a string that I decide + the string of the name of the source file. So in the destination folder there should be 5 empty files with name:
StringDestination1+StringOrigin.Dat
StringDestination2+StringOrigin.Dat
StringDestination3+StringOrigin.Dat
StringDestination4+StringOrigin.Dat
StringDestination5+StringOrigin.Dat
The destination string is fixed and I'll decide within the batch file. The user does not insert any data.
For example, in our case:
string1123456789.dat
string2123456789.dat
string3123456789.dat
string4123456789.dat
string5123456789.dat
I hope I have explained well my problem.
I will be very much grateful to anyone who can solve this problem!
One smack for all!
Read and create files with . bat
Moderator: DosItHelp
Re: Read and create files with . bat
Are you doing some scripting for a school course?
Have a go and see what you can come up with, and then ask some specific questions about the problems you find.
Have a go and see what you can come up with, and then ask some specific questions about the problems you find.
-
- Posts: 2
- Joined: 29 Oct 2013 18:25
Re: Read and create files with . bat
Good morning,
I'm not a student.
I'm trying to make this script for the integration of data between two programs for my small company family.
I hope someone help me to solve the problem.
If you have additional questions or requests do not hesitate to contact me.
Have a nice day,
Miriam
I'm not a student.
I'm trying to make this script for the integration of data between two programs for my small company family.
I hope someone help me to solve the problem.
If you have additional questions or requests do not hesitate to contact me.
Have a nice day,
Miriam
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
-
- Expert
- Posts: 1166
- Joined: 06 Sep 2013 21:28
- Location: Virginia, United States
Re: Read and create files with . bat
And also http://ss64.com/nt/for_f.html because I'm apparently only allowed to post two URLs at once.
Re: Read and create files with . bat
Here a example code:
The batch find one txt-file in the folder "C:\source\". If you have more files the batch is only used one file.
The last row will display the possible file name.
It is possible to make empty files. But if you use a file that is exist then you overwrite this file.
Code: Select all
@echo off
set StringDestination=###
for %%a in ("C:\source\*.txt") do set StringOrigin=%%~na
for /l %%d in (1, 1, 5) do echo File: "C:\OutputFolder\%StringDestination%%%d%StringOrigin%.dat"
The batch find one txt-file in the folder "C:\source\". If you have more files the batch is only used one file.
The last row will display the possible file name.
It is possible to make empty files. But if you use a file that is exist then you overwrite this file.
-
- Posts: 10
- Joined: 21 Nov 2013 01:07
Re: Read and create files with . bat
Type "help for" on the command prompt for more information. (don't know if that works in whatever "DOS" you are telling)