Forum Home
Press F1
 
Thread ID: 108374 2010-03-26 03:30:00 .bat file SolMiester (139) Press F1
Post ID Timestamp Content User
870054 2010-03-26 03:30:00 Hey, calling batch file gurus....

I need to copy a file to all users personal directory from the root above and overwrite existing...

can anyone help?

ta
SolMiester (139)
870055 2010-03-26 04:14:00 #!/bin/sh
STARTDIR="/home/users"
FILENAME="copyme.txt"
cd "$STARTDIR"
ls | while read f; do
if [ -d "$f" ]; then
cp -f "$FILENAME" "$f/$FILENAME" || echo "Failed to copy into $f" >&2;
fi
done
Erayd (23)
870056 2010-03-26 04:51:00 for /f %%a in ('dir /b /a:d') do copy /y textfile.txt "%%a"

If you want to run it as a command instead of in a batch file, just use 1 x % sign.
fred_fish (15241)
870057 2010-03-26 06:03:00 Oops - ignore my previous post - it's a posix shell script, and won't run on Windows. My bad. Erayd (23)
1