Solved

Determining copy date

Posted on 2013-01-11
16
499 Views
Last Modified: 2013-01-15
Is there a tool or command to run against files on a usb drive to determine the date they were copied to that drive?
0
Comment
Question by:FOX
  • 8
  • 8
16 Comments
 
LVL 13

Expert Comment

by:Gabriel Clifton
ID: 38768005
Change for your needs

@echo off
setlocal DisableDelayedExpansion
for %%f in (created modified accessed) do if exist %%f.txt del %%f.txt
set "folder=%CD:~2%"
for /F "skip=1 tokens=1-3*" %%a in (
    '"wmic datafile where (path='%folder:\=\\%\\') get InstallDate, LastModified,

LastAccessed, Name"'
                                   ) do (
   for /F "delims=." %%A in ("%%a") do echo %%A %%d>> created.txt
   for /F "delims=." %%B in ("%%b") do echo %%B %%d>> modified.txt
   for /F "delims=." %%C in ("%%c") do echo %%C %%d>> accessed.txt
)

rem Process each list this way:
for /F "tokens=1*" %%a in (created.txt) do echo %%a - %%b
0
 
LVL 16

Author Comment

by:FOX
ID: 38768037
for %%f in (created modified accessed) do if exist %%f.txt del %%f.txt - Is f the drive letter of the usb drive in this statement?
0
 
LVL 13

Expert Comment

by:Gabriel Clifton
ID: 38768180
no, that would be the variable. you need the line set "folder=%CD:~2%"
0
 
LVL 16

Author Comment

by:FOX
ID: 38768213
So if the drive is G the script should look like this? Secondly, do I run this as a batch file or from the command prompt?

@echo off
setlocal DisableDelayedExpansion
for %%f in (created modified accessed) do if exist %%f.txt del %%f.txt
set "G=%CD:~2%"
for /F "skip=1 tokens=1-3*" %%a in (
    '"wmic datafile where (path='G:\=\\%\\') get InstallDate, LastModified,

LastAccessed, Name"'
                                   ) do (
   for /F "delims=." %%A in ("%%a") do echo %%A %%d>> created.txt
   for /F "delims=." %%B in ("%%b") do echo %%B %%d>> modified.txt
   for /F "delims=." %%C in ("%%c") do echo %%C %%d>> accessed.txt
)

rem Process each list this way:
for /F "tokens=1*" %%a in (created.txt) do echo %%a - %%b
0
 
LVL 13

Expert Comment

by:Gabriel Clifton
ID: 38768229
set folder=G
0
 
LVL 16

Author Comment

by:FOX
ID: 38768312
Please edit the script to show me exactly what it should look like if I have a usb drive G: in my laptop and I want to see the date the files on it were copied to it.  Secondly how am I running the script? As a batch file, do I have to run it in windows shell?, How do I run it?
0
 
LVL 13

Expert Comment

by:Gabriel Clifton
ID: 38768397
copy the code into notepad and save as file-dates.bat
to run open the bat file (double click)
@echo off
setlocal DisableDelayedExpansion
for %%f in (created modified accessed) do if exist %%f.txt del %%f.txt
set folder=G
for /F "skip=1 tokens=1-3*" %%a in (
    '"wmic datafile where (path='%folder:\=\\%\\') get InstallDate, LastModified, 

LastAccessed, Name"'
                                   ) do (
   for /F "delims=." %%A in ("%%a") do echo %%A %%d>> created.txt
   for /F "delims=." %%B in ("%%b") do echo %%B %%d>> modified.txt
   for /F "delims=." %%C in ("%%c") do echo %%C %%d>> accessed.txt
)

rem Process each list this way:
for /F "tokens=1*" %%a in (created.txt) do echo %%a - %%b

Open in new window

0
 
LVL 16

Author Comment

by:FOX
ID: 38768846
command screen comes up and then disappears...I can see it says cannot find the specified file
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 16

Author Comment

by:FOX
ID: 38780295
Is there anything else I need to do to get this running correctly?
0
 
LVL 13

Expert Comment

by:Gabriel Clifton
ID: 38780324
Sorry, I have been working on some big projects at work. I will look at the script again when I get back to my office
0
 
LVL 16

Author Comment

by:FOX
ID: 38780348
Ok P, I appreciate it.
0
 
LVL 13

Accepted Solution

by:
Gabriel Clifton earned 500 total points
ID: 38780644
Try this:
@echo off
for /F "tokens=1*" %%a in ('fsutil fsinfo drives') do (
   for %%c in (%%b) do (
      for /F "tokens=3" %%d in ('fsutil fsinfo drivetype %%c') do (
         if %%d equ Removable (
            echo Drive %%c is Removable (USB^)
SETLOCAL ENABLEEXTENSIONS
SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "tokens=1,* delims= " %%A IN ('DIR /T:C /A:-D %%c ^|FIND "/"') DO (
SET Cdate=%%A
SET Fname=%%B
SET Fname=!Fname:~24!
ECHO File: !FnamE! Created on: !CDate!>> created.txt
)
         )
      )
   )
)

Open in new window

I tried it on my Win7 X64 system. It looks for removable drives and lists files and creation date of each.
0
 
LVL 16

Author Comment

by:FOX
ID: 38780945
I am using the same exact script you have there. My usb drive is in my laptop as drive F:  I don't have to change anything in the script at all?  I have the same specs as you do.  Win7 x64.  The usb drive has about 1.67gb of data on it.  When I first started the script I saw the light on the usb fluctuating as if something was going on, so I will give it some time.  If there are any results are they going to be piped to the created.txt on the usb drive or on the laptop?
0
 
LVL 13

Expert Comment

by:Gabriel Clifton
ID: 38780958
It will go to the directory where it was ran from. you can change that by modifying >>directory\created.txt
0
 
LVL 16

Author Comment

by:FOX
ID: 38780996
P, that was it!!!!  I piped the file to location of my choice, not only that, I needed to right-click and run the batch file as administrator.  Thank you!!!!
0
 
LVL 13

Expert Comment

by:Gabriel Clifton
ID: 38780997
No problem, glad to help.
0

Featured Post

Are end users causing IT problems again?

You’ve taken the time to design and update all your end user’s email signatures, only to find out they’re messing up the HTML, changing the font and ruining the imagery. What can you do to prevent this? Find out how you can save your signatures from end users today.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
exchange support of mac 2 49
Windows Backup image 3 24
Register AutoHotkey 12 41
What is this Task? 4 42
A Bare Metal Image backup allows for the restore of an entire system to a similar or dissimilar hardware. They are highly useful for migrations and disaster recovery. Bare Metal Image backups support Full and Incremental backups. Differential backup…
In this article, I will show you HOW TO: Install VMware Tools for Windows on a VMware Windows virtual machine on a VMware vSphere Hypervisor 6.5 (ESXi 6.5) Host Server, using the VMware Host Client. The virtual machine has Windows Server 2016 instal…
Windows 8 comes with a dramatically different user interface known as Metro. Notably missing from the new interface is a Start button and Start Menu. Many users do not like it, much preferring the interface of earlier versions — Windows 7, Windows X…
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …

744 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

10 Experts available now in Live!

Get 1:1 Help Now