Solved

cannot make it run as a batch file

Posted on 2013-01-15
3
265 Views
Last Modified: 2013-01-15
I am able to run the following from the command prompt with success, but I cannot make it run as a batch file any help making this run from a .bat file is appreciated

CD /D "D: \PDFBills"
set "source=D: \PDFBills\UnZip"
set "targetRoot=D:\ PDFBills\MonthlyPDFBills"
for %F in ("%source%\*") do (
  for /f "tokens=1,2,3 delims=/ " %A in ("%~tF") do (
    if not exist "%targetRoot%\%C\%A" mkdir "%targetRoot%\%C\%A"
    move "%~fF" "%targetRoot%\%C\%A"
  )
)

Lori
0
Comment
Question by:NLITech
  • 2
3 Comments
 
LVL 43

Accepted Solution

by:
Steve Knight earned 500 total points
ID: 38780916
You have a space in the source/dest line for starters, but most of all any % syntax within for commands need to be doubled to %% in batch files.  Try this for starters.

Steve

@echo off
CD /D "D:\PDFBills"
set source=D:\PDFBills\UnZip
set targetRoot=D:\PDFBills\MonthlyPDFBills
for %%F in ("%source%\*") do (
  for /f "tokens=1,2,3 delims=/ " %%A in ("%%~tF") do (
    if not exist "%targetRoot%\%%C\%%A" mkdir "%targetRoot%\%%C\%%A"
    move "%%~fF" "%targetRoot%\%%C\%%A"
  )
)

Open in new window


Steve
0
 

Author Closing Comment

by:NLITech
ID: 38780944
Perfect! Thank you.
0
 
LVL 43

Expert Comment

by:Steve Knight
ID: 38781502
no problem
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

This article was inspired by a question here at Experts Exchange (http://www.experts-exchange.com/Software/Photos_Graphics/Images_and_Photos/Q_28629170.html). The requirements stated in that question are (1) reduce the file size of a large number of…
Introduction: Recently, I got a requirement to zip all files individually with batch file script in Windows OS. I don't know much about scripting, but I searched Google and found a lot of examples and websites to complete my task. Finally, I was ab…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

832 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