copy with regular expression how to
Moderator: DosItHelp
-
- Posts: 9
- Joined: 02 Oct 2014 11:54
copy with regular expression how to
i have these 2 files
NY_20180110_082629.xml
NY_20180110_082629_response.xml
and i have a basic command like
copy /y NY_<SysDate.yyyymmdd>_<SysTime.HH>*.xml e:\Apps
that command is actual run from the tool called tidal software which is basically a job scheduling software.
what happens is that both files are being copied together. i need only to copy the first file which is the NY_20180110_082629.xml and exclude the 2nd file NY_20180110_082629_response.xml. basically the file that i need to copy the file is the NY_<yyyymmdd>_<hhmmss>.xml format.
please advise. thank you.
NY_20180110_082629.xml
NY_20180110_082629_response.xml
and i have a basic command like
copy /y NY_<SysDate.yyyymmdd>_<SysTime.HH>*.xml e:\Apps
that command is actual run from the tool called tidal software which is basically a job scheduling software.
what happens is that both files are being copied together. i need only to copy the first file which is the NY_20180110_082629.xml and exclude the 2nd file NY_20180110_082629_response.xml. basically the file that i need to copy the file is the NY_<yyyymmdd>_<hhmmss>.xml format.
please advise. thank you.
Re: copy with regular expression how to
Did you try removing the asterisk?
-
- Posts: 9
- Joined: 02 Oct 2014 11:54
Re: copy with regular expression how to
yes and it will not work because if I removed the wildcard (asterisk) it will translate to
NY_20180110_08.xml
the file is in NY_20180110_082629.xml
NY_20180110_08.xml
the file is in NY_20180110_082629.xml
Re: copy with regular expression how to
This is really out of scope for DosTips.com. Your problem is with the scheduling software you are using and has nothing to do with Windows batch files or other Windows Scripting Languages.
I bet if you read the user guide you would find your answer.
I bet if you read the user guide you would find your answer.
-
- Posts: 9
- Joined: 02 Oct 2014 11:54
Re: copy with regular expression how to
actually it is the scheduling tool that execute the windows command. i supply the windows command to the scheduling tool and it will execute it.
Re: copy with regular expression how to
The variables you are using are coming from the Tidal. So in essence you are working within the confines of the Tidal Scheduling software. I don't think we have too many subject matter experts on that software around here.warrentolentino wrote: ↑11 Jan 2018 10:46actually it is the scheduling tool that execute the windows command. i supply the windows command to the scheduling tool and it will execute it.
Cisco has a community forum that you can get help with for all their products.
https://supportforums.cisco.com/t5/tida ... enterprise
-
- Posts: 9
- Joined: 02 Oct 2014 11:54
Re: copy with regular expression how to
that is true the variables are coming from tidal but does not mean that is is confine to tidal. its a long explanation how the variables work but i have used it countless of times in conjunction with the windows command and is not a problem. but to make it short the variable <SysDate.yyyymmdd>_<SysTime.HH> is translated into:Squashman wrote: ↑11 Jan 2018 10:53The variables you are using are coming from the Tidal. So in essence you are working within the confines of the Tidal Scheduling software. I don't think we have too many subject matter experts on that software around here.
Cisco has a community forum that you can get help with for all their products.
https://supportforums.cisco.com/t5/tida ... enterprise
20180110_08
it will stop right there without the wildcard because the command "copy /y NY_<SysDate.yyyymmdd>_<SysTime.HH>.xml e:\Apps" will translate to
copy /y NY_20180110_08.xml e:\Apps
anyway on the command line i tried different approach using a findstr:
dir /b NY_20180110_* | findstr /i /r "[0-9$].xml"
on the windows command line i tried to use the dir with combination of findstr command. it was able to find the file that i am looking for. the last part was that how can i use that result to the copy command. so i can copy that file to another folder.
i tried this but it looks like the command is not right
R:\>copy NY_20180110_* | findstr /i /r "[0-9$].xml" sample_file.xml
FINDSTR: Cannot open sample_file.xml
R:\>
Re: copy with regular expression how to
Here is a batch script that may do what I think you wanted. It only ECHOs the copy command.
John A.
Code: Select all
@echo off & setlocal
Set "SysDATE=20180110"
Set "SysTIME=08"
For /F "usebackq tokens=* delims=" %%F in (
`dir /b NY_%SysDATE%_%SysTIME%* ^| findstr /i /r "[0-9$].xml"`
) do Set "File=%%~F"
Echo.copy %File% e:\Apps
Pause
Re: copy with regular expression how to
Please include information like this in your initial request. While it was probably likely that <SysTime.HH> expanded to the 08 in the file names, making assumptions in code is a great way to cause horrible problems, so we need as much information as possible. Now, with this new information, if you are still constrained to the Tidal application I can suggest trying:warrentolentino wrote: ↑11 Jan 2018 09:59yes and it will not work because if I removed the wildcard (asterisk) it will translate to
NY_20180110_08.xml
Code: Select all
copy /y NY_<SysDate.yyyymmdd>_<SysTime.HH>????.xml e:\Apps