Solved

Batch File Script to move files from changing directories

Posted on 2015-02-12
4
137 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 23

Accepted Solution

by:
NVIT earned 500 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 23

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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
A short article about a problem I had getting the GPS LocationListener working.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

746 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now