Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have a small batch file that uses robocopy to backup a folder. The intended action is for it to copy C:/users/public/ into D:/Backups/YYYY-MM-DDTHHMM/

At present, it copies the files into a folder, however the folder name appears in Windows Explorer as 'Public' instead of the requested file name. Stranger still, if I dir the folder from cmd (or check the security tab of it's properties) it appears as the name I desire!

Batch file:

@ECHO OFF
for /f "skip=1" %%x in ('wmic os get localdatetime') do if not defined MyDate set MyDate=%%x

set today=%MyDate:~0,4%-%MyDate:~4,2%-%MyDate:~6,2%T%MyDate:~8,2%%MyDate:~10,2%

robocopy C:/users/Public D:/Backups/%today%
share|improve this question
    
I have searched superuser and found the similar question superuser.com/questions/567331/… , but I hope my description is clear enough to lead to a more useful solution. –  Garth Oates Apr 22 at 11:05
    
Found the solution. Because I was copying the windows directory Public; the desktop.ini file contained within it was changing the apparent folder name. Changing the robocopy line to: robocopy C:/users/Public D:/Backups/%today% /XF desktop.ini Excludes the windows appearance file and completes the job perfectly. I can't answer my own question for 8 hours but I'll add the answer then. –  Garth Oates Apr 22 at 12:36

1 Answer 1

up vote 0 down vote accepted

Because I was copying the windows directory Public; the desktop.ini file contained within it was changing the apparent folder name.

Changing the robocopy line to: robocopy C:/users/Public D:/Backups/%today% /XF desktop.ini

Excludes the windows appearance file and completes the job perfectly.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.