Batch file path issue - URGENT

Dreamslogic
Dreamslogic used Ask the Experts™
on
Hi there,

Thanks once again.

Issue is my PLUSales files are inside the StoreFiles(Directory).  IMy Productcatalog is working fine but PLUSale need some changes

FileSystem Struture:
 
StoreFiles(Directory) --> ProdcutCatalog.csv
StoreFiles(Directory) --> PLUSales(Folder1) --> PLUSales1.csv
StoreFiles(Directory) --> PLUSales(Folder2) --> PLUSales3.csv
StoreFiles(Directory) --> PLUSales(Folder2) --> PLUSales4.csv

Solution Required:

OsPos(Directory) --> BUNDABERG (With all Zipped files in this folder)


Script:
 
set SSIS_FTPFILE_ORG=I:\Information Technology\Retail\Durga\OsPos\Store Files\
set SSIS_FTPFILE_DEST=I:\Information Technology\Retail\Durga\OsPos
set LOGFILE=%SSIS_FTPFILE_DEST%zbatlog%curdate%.txt
 
 
"C:\Program Files\7-zip\7z.exe" a "%SSIS_FTPFILE_DEST%\BUNDABERG.zip" "%SSIS_FTPFILE_ORG%\ProductCatalog*.csv" >>"%LOGFILE%"
"C:\Program Files\7-zip\7z.exe" a "%SSIS_FTPFILE_DEST%\BUNDABERG.zip" "%SSIS_FTPFILE_ORG%\..\PluSales*.csv" >>"%LOGFILE%


Please help me its urgent

Thanks,



Thanks for the help,

D
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Commented:
Hi

According to 7-zip command & switches you must enter "-r0" switch to include "Enable recurse subdirectories only for wildcard names".
Try it and please let me know is it ok or not on my mail address.
Try changing
"C:\Program Files\7-zip\7z.exe" a "%SSIS_FTPFILE_DEST%\BUNDABERG.zip" "%SSIS_FTPFILE_ORG%\PluSales*.csv" >>"%LOGFILE%

to:
"C:\Program Files\7-zip\7z.exe" a -r "%SSIS_FTPFILE_DEST%\BUNDABERG.zip" "%SSIS_FTPFILE_ORG%\PluSales*\PluSales*.csv" >>"%LOGFILE%


http://dotnetperls.com/7-zip-examples

Author

Commented:
Hi there,

No its not woking, it doesn't do anything. Below is my file struture. I used wild card with 'a' and without 'a' command. Also -r0 command still doesn't work. Any idea. I need to ZIP 40 to 100 GB of data over night. It's urgent any help much appreciated.

FileSystem Struture:
 
StoreFiles(Directory) --> ProdcutCatalog.csv
StoreFiles(Directory) --> PLUSales(Folder1) --> PLUSales1.csv
StoreFiles(Directory) --> PLUSales(Folder2) --> PLUSales3.csv
StoreFiles(Directory) --> PLUSales(Folder2) --> PLUSales4.csv
OWASP: Forgery and Phishing

Learn the techniques to avoid forgery and phishing attacks and the types of attacks an application or network may face.

Author

Commented:
Hi JMiller,

I made changes as you mentioned above but it takes whole subfolder and zip with main. I just need the file inside the subfoler.

BUNDABERG.zip contains subfolder and ProductCatalogfiles.

FileSystem Struture:
 
StoreFiles(Directory) --> ProdcutCatalog.csv
StoreFiles(Directory) --> PLUSales(Folder1) --> PLUSales1.csv
StoreFiles(Directory) --> PLUSales(Folder2) --> PLUSales3.csv
StoreFiles(Directory) --> PLUSales(Folder2) --> PLUSales4.csv
Solution Required:

OsPos(Directory) --> BUNDABERG (With all Zipped files in this folder) both ProductCatalog and PLUSales

If you are in a hurry and just need it to work, you can do each folder individually:
"C:\Program Files\7-zip\7z.exe" a -r "%SSIS_FTPFILE_DEST%\BUNDABERG.zip" "%SSIS_FTPFILE_ORG%\PluSales(folder1)\PluSales*.csv" >>"%LOGFILE%

"C:\Program Files\7-zip\7z.exe" a -r "%SSIS_FTPFILE_DEST%\BUNDABERG.zip" "%SSIS_FTPFILE_ORG%\PluSales(folder2)\PluSales*.csv" >>"%LOGFILE%

"C:\Program Files\7-zip\7z.exe" a -r "%SSIS_FTPFILE_DEST%\BUNDABERG.zip" "%SSIS_FTPFILE_ORG%\PluSales(folder3)\PluSales*.csv" >>"%LOGFILE%

I was trying to find you a wildcard version, but this should at least get it working for you.


Author

Commented:
Thanks again,

My SSIS package creates exactly same as you mentioned above but my task it to get those files into one place. so from there again SSIS package runs and load all the records into fact table.

I will wait for you, can you please let me know the wildcard version for folders instead of files.

Sorry to being pain, but this is bit critical to load. Please help me out.
Doesn't running those three commands put all of the files in the archive BUNDABERG.zip? According to 7-Zip docs, the a command will either create a new archive or add files to an existing one.

Author

Commented:
But to be honest with you, I got 350 subfolders and all the subfolders got PLUSales.csv files. I need to get them into BUNDABERG.zip along with ProductCatalog.csv. - This is for only BUNDABERG site and I got 190 sites all this

You mean to say I need to write 350 times for each subfolder.

Any Idea we can dynamically change that control it. This is really driving me crazy.
Do you have a list of the subfolders? I found something that allows you to bring in the list of subfolders and use it.
http://prudentialscatterbrain.hp.infoseek.co.jp/7z-4.20_MANUAL/syntax.htm

"List file
You can supply one or more filenames or wildcards for special list files (files containing lists of files). The filenames in such list file must be separated by space, tab or new line symbol(s). Wildcards or filenames with spaces must be quoted.

For list files 7-Zip uses OEM (DOS) encoding.

Multiple list files are supported.

For example, if contents of file "listfile.txt" is the following:

    "My programs\*.cpp"
    Src\*.cpp

then command

    7z a -tzip archive.zip @listfile.txt

adds to archive "archive.zip" all "*.cpp" files from directories "My programs" and "Src"."
 
This one should work. I found the -ir! switch on this site.
http://www.bugaco.com/7zip/MANUAL/switches/include.htm

"C:\Program Files\7-zip\7z.exe" a "%SSIS_FTPFILE_DEST%\BUNDABERG.zip" -ir!"%SSIS_FTPFILE_ORG%\PluSales*\PluSales*.csv" >>"%LOGFILE%

Author

Commented:
Thank you very much for your time. However, above script didn't help. It will move the whole folder instead of file. I have to sit whole night now, extract each file and place it in a folder and load into fact table.

Sorry mate !!

Thanks for your help, some tiems it  doesn't go our way !! :(



Author

Commented:
User is very helpful. We both tried ,probably someone can you the code.
But I appreciate his input.
When I tested it, (the -ir! switch) I only pulled in the files that were *.csv and not the folder.

If you are moving all of them anyway, you may as well use the script to zip them up and save yourself some time. Dump them in a folder and change the origin to that folder.

You're right, sometimes this 'stuff' doesn't go our way, but it irritates me to death to not find a solution. Especially if it costs someone else a bunch of time. I sit in front of a keyboard many hours in a day by choice (at work and at home), but I try to free up someone else that wants to get away.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial