Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Windows Batch filename contains...

Posted on 2008-06-11
9
Medium Priority
?
478 Views
Last Modified: 2010-04-21
The network location may contain upto three zips with the letters NTO, PCN, or BLE in the filename
i need to modify the code below so that when it connects and copys everything from the network location. If the filename contains NTO it puts it into e:\folder\NTO\ if it contains PCN it puts it into e:\folder\PCN if it contains BLE it moves it to BLE etc etc.

then it renames the file to export.zip

then using pzunzip (picozip) it needs to unzip the contents to the current location and rename the file without an extension to 'export' for BLE, PCN and NTO and then delete the contents on the remote share and then remove the network drive.

Previously it was just one zip so the code worked fine however i need to change it now.

any ideas?




i

@Echo Off
del e:\folder\images\*.* /q
NET USE i: \\129.3.10.16\folder /USER:server\username password
XCOPY i:\*.* e:\folder\images\*.* 
FOR %%A IN (e:\bus_lane\images\*.ZIP) DO IF NOT "%%~A"=="e:\folder\images\Export.ZIP" REN %%~A Export.ZIP
pzunzip e:\folder\images\export.zip e:\folder\images\
del i:\*.* /q
NET USE i: /DELETE /Y
cd e:\folder\images\
ren *. export

Open in new window

0
Comment
Question by:superblades
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
9 Comments
 
LVL 67

Expert Comment

by:sirbounty
ID: 21759010
Something like this should work - remove the ECHO below to make it actually process the files...
for /f "tokens=*" %%T in ('dir /b e:\folder\images\*NTO*') do ECHO move "%%T" e:\folder\NTO
for /f "tokens=*" %%T in ('dir /b e:\folder\images\*PCN*') do ECHO move "%%T" e:\folder\PCN
for /f "tokens=*" %%T in ('dir /b e:\folder\images\*BLE*') do ECHO move "%%T" e:\folder\BLE

Open in new window

0
 
LVL 4

Author Comment

by:superblades
ID: 21759323
I get

'the system cannot find the file specified'
'the system cannot find the file specified'
'the system cannot find the file specified'

?

Its copying them across ok but just not moving them

@Echo Off
del e:\folder\images\*.* /q
NET USE i: \\129.3.10.16\folder /USER:server\username password
XCOPY i:\*.* e:\folder\images\*.*
for /f "tokens=*" %%T in ('dir /b e:\folder\images\*NTO*') do move "%%T" e:\folder\NTO
for /f "tokens=*" %%T in ('dir /b e:\folder\images\*PCN*') do move "%%T" e:\folder\PCN
for /f "tokens=*" %%T in ('dir /b e:\folder\images\*BLE*') do move "%%T" e:\folder\BLE

0
 
LVL 67

Expert Comment

by:sirbounty
ID: 21759411
Think I see it...specify the path as well..

XCOPY i:\*.* e:\folder\images\*.*
for /f "tokens=*" %%T in ('dir /b e:\folder\images\*NTO*') do move "%%~dpnxT" e:\folder\NTO
for /f "tokens=*" %%T in ('dir /b e:\folder\images\*PCN*') do move "%%~dpnxT" e:\folder\PCN
for /f "tokens=*" %%T in ('dir /b e:\folder\images\*BLE*') do move "%%~dpnxT" e:\folder\BLE
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 4

Author Comment

by:superblades
ID: 21759475
no joy
same problem

Regards

Superblades
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 21759561
what was the 'echo' display from my first post?
0
 
LVL 4

Author Comment

by:superblades
ID: 21759652
its looking for e:\folder\file not e:\folder\images\file


move "E:\folder\0530NTO02.zip" e:\folder\NTO
move "E:\folder\0530PCN02.zip" e:\folder\PCN
move "E:\folder\0530BLE02.zip" e:\folder\BLE

Open in new window

0
 
LVL 67

Accepted Solution

by:
sirbounty earned 2000 total points
ID: 21759699
Hmm - that's a bit odd, but you can override it with:

for /f "tokens=*" %%T in ('dir /b e:\folder\images\*NTO*') do move "e:\folder\images\%%T" e:\folder\NTO\
for /f "tokens=*" %%T in ('dir /b e:\folder\images\*PCN*') do move "e:\folder\images\%%T" e:\folder\PCN\
for /f "tokens=*" %%T in ('dir /b e:\folder\images\*BLE*') do move "e:\folder\images\%%T" e:\folder\BLE\
0
 
LVL 4

Author Closing Comment

by:superblades
ID: 31466098
Thanks spot on!
0
 
LVL 67

Expert Comment

by:sirbounty
ID: 21760251
Still...puzzling why the other method wouldn't work, but glad it's sorted. :^)
Thanx for the grade.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

If like me you are one who spends a lot of time working and scripting with cmd.exe, sometimes it is handy to be able to quickly view a calendar for a given month and year. This script will quickly do just that!  Save the code posted below to a .bat …
How to remove superseded packages in windows w60 or w61 installation media (.wim) or online system to prevent unnecessary space. w60 means Windows Vista or Windows Server 2008. w61 means Windows 7 or Windows Server 2008 R2. There are various …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

604 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