1.

Solve : Batch file to make new folder fails to work?

Answer»

Hello,

I have attached a batch file that i use to make a new folder in date format in a certain directory.
when i run the file as it is it does'nt work.

if i CHANGE the file to run on c directory i have no problems but when i change it to example on attached
it fails.
The u drive in example is on a shared network drive.

This is puzzling since it works on c drive.

Any advice would be great.
Thanks

[recovering disk space, attachment deleted by admin]This is your code:

Code: [Select]@echo off
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET date="%date:~0,2%-%date:~3,2%-%date:~6,6%"
md 'filesvr-tms' u:\dropsets\before\testerpost\%date%
The last line should be something like this:

Code: [Select]md "u:\dropsets\before\testerpost\%date%"

The first four lines of this code will give you reliable YY DD MM YYYY HH Min Sec variables in XP Pro and higher.

Code: [Select]@echo off
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set "YY=%dt:~2,2%" & set "YYYY=%dt:~0,4%" & set "MM=%dt:~4,2%" & set "DD=%dt:~6,2%"
set "HH=%dt:~8,2%" & set "Min=%dt:~10,2%" & set "Sec=%dt:~12,2%"

set "datestamp=%YYYY%%MM%%DD%" & set "timestamp=%HH%%Min%%Sec%"
set "fullstamp=%YYYY%-%MM%-%DD%_%HH%-%Min%-%Sec%"
echo datestamp: "%datestamp%"
echo timestamp: "%timestamp%"
echo fullstamp: "%fullstamp%"
pause
md 'filesvr-tms' u:\dropsets\before\testerpost\%date%
^^^^^^^^^^^^^
|
what is this supposed to do?


C:\>md /?
Creates a directory.

MKDIR [drive:]path
MD [drive:]path

Hello,

On a shared drive "U" ,everyday i have to scroll to that drive and create a new folder with the current DAYS date.

so i figured creating a batch file that could sit on the desktop and when clicked would do such a task.
When i run the attached file at home it writes it with no problems.
But in work it does'nt seem to work so i thought maybe i need to include the filesvr-tms for the file server running it
but still no joy.

I can't figure why it works at home but not in work.Quote from: ftfk on October 24, 2013, 02:03:32 PM

I can't figure why it works at home but not in work.

Possibly you do not have sufficient permissions. If this is a work computer you need to contact the system administrator. Also, does the %date% variable CONTAIN characters that would be illegal in a file or folder name?
usually permission restrictions on the network gives a pop up message.
But running this gives nothing.

The date variable as from attached example contains nothing illegal.Quote from: ftfk on October 24, 2013, 02:14:10 PM
usually permission restrictions on the network gives a pop up message.
But running this gives nothing.

The date variable as from attached example contains nothing illegal.

You won't necessarily get a POPUP with a batch script. Try adding this one line to the end of the batch script:

PAUSE

Then the command window will stay open until you press a key and you can see if the system is trying to tell you anything.







Discussion

No Comment Found