Skip to content
View in the app

A better way to browse. Learn more.

MSFN

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

File Copy and FTP Script

Featured Replies

Hello,

Does anyone have a VB Script that will check a specific folder on a Windows 2000 box for files created only in the last day and move them to another specified folder?

Thanks.


Here is an example which does as your question above asks.

' folder where the files reside
sSourceFolder = "C:\mysource"

' folder to where files are moved
sTargetFolder = "C:\mytarget"

dDate = Date
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sSourceFolder)
For Each oFile In oFolder.Files
If DateDiff("d", oFile.DateCreated, dDate) = 0 Then
oFile.Move sTargetFolder & "\", True
End If
Next

However from your Subject Title I doubt that this is exactly what you want. You mention FTP, which may mean some files may already exist in the second location making File.Move a bad idea, some files may have been changed, but still have the same DateCreated etc.

Why use a script? Check out Robocopy from Microsoft. a single CMD line with it will do what is sounds like you want.

  • Author
Why use a script? Check out Robocopy from Microsoft. a single CMD line with it will do what is sounds like you want.

I looked at the RoboCopy. It doesn't allow me to set a time frame of which to copy files. For instance. I only want to get files that were created in the last 3 days. It doesn't seem to allow me to specify the time of which to only copy the files.

Thanks for the suggestion tho'.

Yzöwl I'm going to give this script a try. I'll keep you posted.

Thanks.

I believe you are after the MAXAGE or MINAGE switches.

From Robocopy /? help:

::

:: File Selection Options :

::

/A :: copy only files with the Archive attribute set.

/M :: copy only files with the Archive attribute and reset it.

/IA:[RASHCNETO] :: Include only files with any of the given Attributes set.

/XA:[RASHCNETO] :: eXclude files with any of the given Attributes set.

/XF file [file]... :: eXclude Files matching given names/paths/wildcards.

/XD dirs [dirs]... :: eXclude Directories matching given names/paths.

/XC :: eXclude Changed files.

/XN :: eXclude Newer files.

/XO :: eXclude Older files.

/XX :: eXclude eXtra files and directories.

/XL :: eXclude Lonely files and directories.

/IS :: Include Same files.

/IT :: Include Tweaked files.

/MAX:n :: MAXimum file size - exclude files bigger than n bytes.

/MIN:n :: MINimum file size - exclude files smaller than n bytes.

/MAXAGE:n :: MAXimum file AGE - exclude files older than n days/date.

/MINAGE:n :: MINimum file AGE - exclude files newer than n days/date.

/MAXLAD:n :: MAXimum Last Access Date - exclude files unused since n.

/MINLAD:n :: MINimum Last Access Date - exclude files used since n.

(If n < 1900 then n = n days, else n = YYYYMMDD date).

/XJ :: eXclude Junction points. (normally included by default).

  • Author
Here is an example which does as your question above asks.
' folder where the files reside
sSourceFolder = "C:\mysource"

' folder to where files are moved
sTargetFolder = "C:\mytarget"

dDate = Date
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder(sSourceFolder)
For Each oFile In oFolder.Files
If DateDiff("d", oFile.DateCreated, dDate) = 0 Then
oFile.Move sTargetFolder & "\", True
End If
Next

However from your Subject Title I doubt that this is exactly what you want. You mention FTP, which may mean some files may already exist in the second location making File.Move a bad idea, some files may have been changed, but still have the same DateCreated etc.

what is the format for the Date?

In order to find out, create a vbs containing this:

wscript.echo date

and double-click it.

I looked at the RoboCopy. It doesn't allow me to set a time frame of which to copy files. For instance. I only want to get files that were created in the last 3 days. It doesn't seem to allow me to specify the time of which to only copy the files.
As IcemanND has mentioned, try
/MAXAGE:3

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.