Computing.Net > Forums > Programming > Script to move/delete files

Computing.Net: Over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to sign up now, it's free!

Script to move/delete files

Reply to Message Icon

Original Message
Name: sreg73
Date: January 8, 2007 at 07:45:20 Pacific
Subject: Script to move/delete files
OS: Win 2003 Server
CPU/Ram: 3.2 GHZ / 3.5 GB
Manufacturer/Model: HP DL 380
Comment:

I am trying to write a batch script that moves all files from one network folder to another network folder. On the destination folder, I need to delete any files older than 3 days from after the move occurred. So if they files were moved on 1/8/07, they need to be deleted after 1/11/07. Here's what I have so far:

@echo on&setlocal ENABLEDELAYEDEXPANSION
echo %*|fs /c:"Database backed up:"||exit 1
move x:\*.* y:\

The move is not working with this script, and I didn't know how to acquire the date stamp for the deletion. Thanks!!


Report Offensive Message For Removal


Response Number 1
Name: Mechanix2Go
Date: January 9, 2007 at 05:19:20 Pacific
Reply: (edit)

What is this line trying to do and what is fs?


echo %*|fs /c:"Database backed up:"||exit 1

Basically 'deleting older than' entails 'date math' and if you cruise through the last few hundred msgs, you'll see that no one has had much luck.



=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal

Response Number 2
Name: sreg73
Date: January 10, 2007 at 05:06:59 Pacific
Reply: (edit)

The line
echo %*|fs /c:"Database backed up:"||exit 1
just basically echos out some information about the database being backed up. If I could just get the move part working, that would be fine. I was trying to use a For statement and I came up with something like this:
for %%B in (X:\ABC\*.BAK) do (move %%B Y:\USA Backup)
This line works in a live DOS session, but does not work when I run the script. Thanks!


Report Offensive Follow Up For Removal

Response Number 3
Name: Mechanix2Go
Date: January 10, 2007 at 05:29:02 Pacific
Reply: (edit)

I still don't get what's up with fs and exit.


=====================================
If at first you don't succeed, you're about average.

M2



Report Offensive Follow Up For Removal







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home








Do you have your own blog?

Yes
No
I did before
I will soon


View Results

Poll Finishes In 2 Days.
Discuss in The Lounge
Poll History




Data Recovery Software