?
Solved

Microsoft Batch File (Variable filename with space in)

Posted on 2012-09-20
4
Medium Priority
?
1,018 Views
Last Modified: 2012-09-20
I need to get the following batch line working but I’m coming up with an issue when the files have a space in them.

for %%X in (*.7z) DO 7zg x %%X -oG:\Data\FTPTemp\sop –y

The file name is “SOP 200912.7z”

Many thanks,
Glyn
0
Comment
Question by:Glyn Merritt
4 Comments
 
LVL 14

Accepted Solution

by:
frankhelk earned 1000 total points
ID: 38418320
Try

for %%X in (*.7z) DO 7zg x "%%X" -oG:\Data\FTPTemp\sop –y

Open in new window

0
 
LVL 1

Author Closing Comment

by:Glyn Merritt
ID: 38418338
Hi Frank

Got it! thank you.

Cheers,
Glyn
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38418429
BTW You might also want to use  "%%~X".

The ~ removes any quotes that may be around the name as sometimes you can find a process will add "" to filenames that need them and not to others, so I always do this to get to a known state, then you add them back.

Steve
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 38418440
Now there's some great turn around, less than 3 minutes from post to an accepted solution, great work frankhelk!

~bp
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This tutorial will show how to configure a new Backup Exec 2012 server and move an existing database to that server with the use of the BEUtility. Install Backup Exec 2012 on the new server and apply all of the latest hotfixes and service packs. The…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question