Find, Copy and Rename in BATCH
Posted: 22 Jun 2018 05:22
Good Morning!
Coming from another article, which i tried to adopt, but failed, i would like to ask my question here. I need to achieve two things:
Copy all files that contain a certain string in their filename from one directory to another, but only if that file does not already exists in that target directory. The filename could be something like "EventLog_12345.txt" and i would want to copy only the files where the filename contains "EventLog".
In a set of files identify in every .txt file a certain string. This string indicates the line that contains the string i am looking for. I want to get to the end of this line and save the .txt file as a new .txt file with a new name based on the string i find at the end of this line. Example: My file is "EventLog_12345.txt" and somewhere in this file there is a line like this:
2018-06-22 08:21:19 0133 LET vVariable = 'h**ps://somedomain.com/test/1/2/4/jobs/joblog.XML'
The string indicating the line is vVariable. The string i want to use within the new filename in this example is joblog.xml. The file should be stored as a new .txt file with the name: joblog_12345.txt. Note, that the length of the line can vary; so can the length of the domain string; also the names of the XMLs are different. The constant is that i always want to have the name of the XML file which is always the last piece of the domain.
I hope someone can help me with this! Thanks in advance.
Coming from another article, which i tried to adopt, but failed, i would like to ask my question here. I need to achieve two things:
Copy all files that contain a certain string in their filename from one directory to another, but only if that file does not already exists in that target directory. The filename could be something like "EventLog_12345.txt" and i would want to copy only the files where the filename contains "EventLog".
In a set of files identify in every .txt file a certain string. This string indicates the line that contains the string i am looking for. I want to get to the end of this line and save the .txt file as a new .txt file with a new name based on the string i find at the end of this line. Example: My file is "EventLog_12345.txt" and somewhere in this file there is a line like this:
2018-06-22 08:21:19 0133 LET vVariable = 'h**ps://somedomain.com/test/1/2/4/jobs/joblog.XML'
The string indicating the line is vVariable. The string i want to use within the new filename in this example is joblog.xml. The file should be stored as a new .txt file with the name: joblog_12345.txt. Note, that the length of the line can vary; so can the length of the domain string; also the names of the XMLs are different. The constant is that i always want to have the name of the XML file which is always the last piece of the domain.
I hope someone can help me with this! Thanks in advance.