Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Batch File Script to move files from changing directories

Posted on 2015-02-12
4
Medium Priority
?
146 Views
Last Modified: 2015-02-13
Hi,
I need help with how I can get a bat file to move files from folders that change name.
We have 2 files that get generated and they go into folders named "date" (so 2.10.15, 2.11.15, 2.12.15, etc etc)
How do I tell my script how to go to these changing folder names?
Currently I just have:
$ftp = "ftp://123.123.123.123/
$user = "Username"  
$pass = "Password"
$uploadfpath = "L:\Folder1\Archive\Folder2\Folder3\2015\02\20150211"
So it all stay consistent up until Folder3 - then the folders go year, then month and then a folder called 20150211 and in this folder are the 2 files I need to copy to my FTP.
I can get it to work with the above line but that only works for that specific folder/date - tomorrow it will not work.
Any help?
Thanks,
Dan
0
Comment
Question by:Fragclub27
  • 2
  • 2
4 Comments
 
LVL 25

Accepted Solution

by:
NVIT earned 2000 total points
ID: 40606755
for the current date, you can use:
set today=%date%
set yyyy=%today:~-4%
set mm=%today:~4,2%
set dd=%today:~7,2%

$uploadfpath = "L:\Folder1\Archive\Folder2\Folder3\%yyyy%\%mm%\%yyyy%%mm%%dd%" 

Open in new window

0
 
LVL 1

Author Comment

by:Fragclub27
ID: 40607824
Thanks - will test it out now
0
 
LVL 25

Expert Comment

by:NVIT
ID: 40608436
BTW, your code doesn't look like .bat code. But, your topic and title mentions batch, and the body says ...get a bat file... So... I responded anyway.
0
 
LVL 1

Author Comment

by:Fragclub27
ID: 40608445
Sorry - that was my error - it is shell!
0

Featured Post

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.

Question has a verified solution.

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

Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Introduction to Processes

783 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