Logic for Extracting Substrings
Moderators: chulett, rschirm, roy
-
- Premium Member
- Posts: 133
- Joined: Tue Nov 23, 2004 11:24 pm
- Location: India
Logic for Extracting Substrings
Hi All
I am trying to find a set of files with extension .zip from a file folder. I am working around a DOS Script for this which is doing a lot of other functionality..
For some wierd reason when i code in my DOS Script the following Syntax
dir /a-d|find ".zip" It is giving me an error saying
Result = find: unable to access ".zip": The system cannot find the file specified.
The same syntax works fine from the Command Prompt...
Never the less the command dir /b works which is giving me all the files in the directory in short form...
Is there Some String function in Datastage which will Slit through the whole directory brought by dir /b and give me only the names which fit an Pattern like '.zip'...
I am not able to use Field or any other commands as there are no delimeters
Any help will be really appreciated
Thanks
Pavan
I am trying to find a set of files with extension .zip from a file folder. I am working around a DOS Script for this which is doing a lot of other functionality..
For some wierd reason when i code in my DOS Script the following Syntax
dir /a-d|find ".zip" It is giving me an error saying
Result = find: unable to access ".zip": The system cannot find the file specified.
The same syntax works fine from the Command Prompt...
Never the less the command dir /b works which is giving me all the files in the directory in short form...
Is there Some String function in Datastage which will Slit through the whole directory brought by dir /b and give me only the names which fit an Pattern like '.zip'...
I am not able to use Field or any other commands as there are no delimeters
Any help will be really appreciated
Thanks
Pavan
Re: Logic for Extracting Substrings
You are probably not in the directory you think you are in. Are you using fully qualified paths or at least doing a 'cd' to the directory in question before issuing the 'dir' command? A 'cd' that you are sure isn't failing, that is?Pavan_Yelugula wrote:Syntax
dir /a-d|find ".zip" It is giving me an error saying
Result = find: unable to access ".zip": The system cannot find the file specified.
The same syntax works fine from the Command Prompt...
Sure there is. The 'dot' in the filename can typically be used as the delimiter for the Field command... would that not work for you?Pavan_Yelugula wrote:Is there Some String function in Datastage which will Slit through the whole directory brought by dir /b and give me only the names which fit an Pattern like '.zip'...
I am not able to use Field or any other commands as there are no delimeters
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Premium Member
- Posts: 133
- Joined: Tue Nov 23, 2004 11:24 pm
- Location: India
I am doing a CD before i fire the Dir command and i am seeing the files i want to see when i do the dir /b...
And yes the '.' can be used as a delimiter cool
My dir /b is giving this output
In this i want only Temp.zip and Temp1.zip to be returned... Any ideas how i can get them
Thanks
Pavan
And yes the '.' can be used as a delimiter cool
My dir /b is giving this output
Code: Select all
Count1.txt
Count2.txt
Temp.zip
FTPScript_New.bat
Temp1.zip
Thanks
Pavan
-
- Charter Member
- Posts: 822
- Joined: Sat Sep 17, 2005 5:25 pm
- Location: USA
Hi Pavan,
Why no just using. Also what i remeber is that your Find command should have directory path in which it has to search for that .zip file. Something like or might be just add that "*" and try it.
Why no just using
Code: Select all
dir *.zip
Code: Select all
Find dir /a-d "*.zip"
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
Thomas Alva Edison(1847-1931)
-
- Premium Member
- Posts: 133
- Joined: Tue Nov 23, 2004 11:24 pm
- Location: India
-
- Premium Member
- Posts: 133
- Joined: Tue Nov 23, 2004 11:24 pm
- Location: India
Kumar,
Nope it gives the same error
Thanks
Pavan
Nope it gives the same error
Code: Select all
Result = find: unable to access "zip": The system cannot find the file specified.
Pavan
"*.zip" will not work though. It looks for exact string. Just for testing purpose, find if you were able to get the output for "dir /a-d" alone. If thats ok, then check if this gives all the list of files. ie., search for a space.
Code: Select all
dir /a-d | find " "
Impossible doesn't mean 'it is not possible' actually means... 'NOBODY HAS DONE IT SO FAR'
-
- Charter Member
- Posts: 822
- Joined: Sat Sep 17, 2005 5:25 pm
- Location: USA
Still i think there is something not quite correct with your FIND syntax.
Check this:
http://www.computerhope.com/findhlp.htm
Check this:
http://www.computerhope.com/findhlp.htm
I haven't failed, I've found 10,000 ways that don't work.
Thomas Alva Edison(1847-1931)
Thomas Alva Edison(1847-1931)
-
- Premium Member
- Posts: 133
- Joined: Tue Nov 23, 2004 11:24 pm
- Location: India
-
- Charter Member
- Posts: 822
- Joined: Sat Sep 17, 2005 5:25 pm
- Location: USA
-
- Premium Member
- Posts: 133
- Joined: Tue Nov 23, 2004 11:24 pm
- Location: India
Hi Kumar
This is a small part of the code in my script for this logic nothing hi-fi
Same set of commands works fine on comand prompt but doesn't when called from datastage... i wonder as you said it is with the pipe..
Thanks
Pavan
This is a small part of the code in my script for this logic nothing hi-fi
Code: Select all
E:
cd \cdw\dev\Script
dir /a-d|find "zip"
Thanks
Pavan