• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

Looking for a program that auto-transfers files..does it exist?

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

syypher

Member
Joined
Oct 8, 2009
Hi everyone! A very uncommon task has been assigned to me at work. I'm needing to find a way to automatically transfer files to a USB drive when it is plugged into a USB slot on a small computer. We will be using some small computers like Raspberry or other mini designs that are small enough to fit on your hand.

What we want to do is have the customers be able to come in with a USB stick and plug it into the USB slot in the computer and have a video file (.wmv) automatically copy itself to the USB stick. The video file will be different every week so we would need a program/app that can change what file it auto copies to the customers USB stick as well.

Has anyone any knowledge or experience with any such program? Is there any way to do this on a computer or any other device with USB capabilities?
 
@echo off
:start
set backupcmd=xcopy /s /c /d /e /h /i /r /y
%backupcmd% "source directory" "transfer directory"
goto start




Copy it into a new text document, replacing transfer directory with the drive directory that flash drives will be plugged in to ex: "G:\"

Replace "source directory" with the folder directory of the file to be transferred, but do note that it will transfer EVERYTHING from that folder, so put the video in it's own folder.

Finally, save the file under "all files" as (name here).bat, and run it when you are ready to start handing out the files.

This will basically loop that command over and over, transferring files to that directory when a thumb drive is plugged in.
 
@echo off
:start
set backupcmd=xcopy /s /c /d /e /h /i /r /y
%backupcmd% "source directory" "transfer directory"
goto start




Copy it into a new text document, replacing transfer directory with the drive directory that flash drives will be plugged in to ex: "G:\"

Replace "source directory" with the folder directory of the file to be transferred, but do note that it will transfer EVERYTHING from that folder, so put the video in it's own folder.

Finally, save the file under "all files" as (name here).bat, and run it when you are ready to start handing out the files.

This will basically loop that command over and over, transferring files to that directory when a thumb drive is plugged in.

You sir...are a genius. Thank you SO much! :clap:
 
Not just yet...I tested it, but we'll have to see how it goes on your system. :p And I may be posting a revised version to reduce possible processor load...

Thank you :)

I tested it out and it works perfectly. My manager though was interested in trying to find a way to mess with an autorun file to run the batch file only when a USB stick is plugged in instead of constantly.
 
@echo off
:starta
IF NOT EXIST transferdirectory GOTO starta
:startb
set backupcmd=xcopy /s /c /d /e /h /i /r /y
%backupcmd% "source directory" "transfer directory"
echo Transfer completed
:startc
IF EXIST transferdirectory GOTO startc
IF NOT EXIST transferdirectory GOTO starta





More efficient code. Everything that needs to be replaced is in bold.
 
@echo off
:starta
IF NOT EXIST transferdirectory GOTO starta
:startb
set backupcmd=xcopy /s /c /d /e /h /i /r /y
%backupcmd% "source directory" "transfer directory"
echo Transfer completed
:startc
IF EXIST transferdirectory GOTO startc
IF NOT EXIST transferdirectory GOTO starta





More efficient code. Everything that needs to be replaced is in bold.

Thank you! I will test it out right now and report back updating this post.

Update:
Worked! CPU processing reduced drastically as well. Appreciate the help man! Your amazing :)

By any chance would it be possible to copy only the single latest timestamped file in the folder instead of everything in the folder? If not we can work around it. Thanks again!!
 
Last edited:
It will only copy a file if the destination does not already have it, so that shouldn't be an issue if the file only contains the videos...if not, I will do some tweaking to see if I can make it copy only the newest file. :p
 
@echo off
@For /F "tokens=2,3,4 delims=/ " %%A in ('Date /t') do @(
Set Month=%%A
Set Day=%%B
Set Year=%%C
)
SET date=%Month%/%Day%/%Year%
:starta
IF NOT EXIST destination GOTO starta
:startb
echo Transferring...
set backupcmd=xcopy /s /c /d:%date% /e /i /r /y
%backupcmd% "source directory" "destination"
echo Transfer completed
echo -------------------------
:startc
IF EXIST destination GOTO startc
IF NOT EXIST destination GOTO starta



It will only transfer files with a timestamp of the day of running it...if it that doesn't do it for ya, just say so. :p
 
Last edited:
GOT IT. Replace the smiley with : and then D
This will copy ONLY the newest file, and the video must be in the source directory before running the batch file.





@echo off
FOR /F "delims=\" %%I IN ('DIR "source directory" /B /O:D') DO SET NewestFile=%%I
:starta
IF NOT EXIST destination GOTO starta
echo Transferring...
xcopy "source directory\%NewestFile%" "destination" /s /c /d:%date% /e /r /y
echo Transfer complete
echo -------------------------
:startb
IF EXIST destination GOTO startb
IF NOT EXIST destination GOTO starta
 
Last edited:
GOT IT. Replace the smiley with : and then D
This will copy ONLY the newest file, and the video must be in the source directory before running the batch file.





@echo off
FOR /F "delims=\" %%I IN ('DIR "source directory" /B /O:D') DO SET NewestFile=%%I
:starta
IF NOT EXIST destination GOTO starta
echo Transferring...
xcopy "source directory\%NewestFile%" "destination" /s /c /d:%date% /e /r /y
echo Transfer complete
echo -------------------------
:startb
IF EXIST destination GOTO startb
IF NOT EXIST destination GOTO starta

Will test and report back!

Update: The file is erroring out when I plug in the USB drive. Is this correct?

@echo off
FOR /F "delims=\" %%I IN ('DIR "Source Location" /B /O:D') DO SET NewestFile=%%I
:starta
IF NOT EXIST E: GOTO starta
echo Transferring...
xcopy "source location" E: /s /c /d:%date% /e /r /y
echo Transfer complete
echo -------------------------
:startb
IF EXIST E: GOTO startb
IF NOT EXIST E: GOTO starta



I am getting
"Invalid parameter - /d:Thu
Transfer complete"
 
Last edited:
@echo off
FOR /F "delims=\" %%I IN ('DIR "source directory" /B /O:D') DO SET NewestFile=%%I
:starta
IF NOT EXIST destination GOTO starta
echo Transferring...
xcopy "source directory\%NewestFile%" "destination" /s /c /d /e /r /y
echo Transfer complete
echo -------------------------
:startb
IF EXIST destination GOTO startb
IF NOT EXIST destination GOTO starta



Oops.... unnecessary / invalid date reference fixed.
 
Last edited:
PERFECT! The batch file is PERFECT! Does the latest file and it's been tested and runs fine on our machines. Thanks man! Your a life saver :)
 
@echo off
FOR /F "delims=\" %%I IN ('DIR "source directory" /B /O:D') DO SET NewestFile=%%I
:starta
PING 1.1.1.1 -n 1 -w 1000 >NUL
IF NOT EXIST destination GOTO starta
echo Transferring...
xcopy "source directory\%NewestFile%" "destination" /s /c /d /e /r /y
echo Transfer complete
echo -------------------------
:startb
PING 1.1.1.1 -n 1 -w 1000 >NUL
IF EXIST destination GOTO startb
IF NOT EXIST destination GOTO starta



This code will cut down processor load dramatically by introducing a 1 second pause between each loop attempt.

All you have to do is paste

PING 1.1.1.1 -n 1 -w 1000 >NUL

after :starta and :startb as shown above.
 
Last edited:
@echo off
FOR /F "delims=\" %%I IN ('DIR "source directory" /B /O') DO SET NewestFile=%%I
:starta
PING 1.1.1.1 -n 1 -w 1000 >NUL
IF NOT EXIST destination GOTO starta
echo Transferring...
xcopy "source directory\%NewestFile%" "destination" /s /c /d /e /r /y
echo Transfer complete
echo -------------------------
:startb
PING 1.1.1.1 -n 1 -w 1000 >NUL
IF EXIST destination GOTO startb
IF NOT EXIST destination GOTO starta



This code will cut down processor load dramatically by introducing a 1 second pause between each loop attempt.

All you have to do is paste

PING 1.1.1.1 -n 1 -w 1000 >NUL

after :starta and :startb as shown above.

Thanks man! :) I've edited it a bit. We have used the program and it's been great. One thing though, I don't know how to use it in multiple copies and turn it into one batch file...let me explain...

I have 4 batch files now, each looking for USB port U:, V:, X:, Y:
I run them all at start up and I have assigned the ports on my computer to always use assign specific letters to specific ports. Is there a way to turn my 4 batch files (All the same code you did for me except 4 different instances) into 1 batch file? If it finds U: it will copy latest file from folder X:, if it finds V: usb drive it will copy latest file from folder Z.

Thanks :)
 
@echo off
:starta
PING 1.1.1.1 -n 1 -w 1000 >NUL
IF NOT EXIST destinationA GOTO startc
IF EXIST destinationA
FOR /F "delims=\" %%I IN ('DIR "source directoryA" /B /O') DO SET NewestFile=%%I
echo Transferring...
xcopy "source directoryA\%NewestFile%" "destinationA" /s /c /d /e /r /y
echo Transfer complete
echo -------------------------
:startb
PING 1.1.1.1 -n 1 -w 1000 >NUL
IF EXIST destinationA GOTO startb
IF NOT EXIST destinationA GOTO starta

:startc
IF NOT EXIST destinationB GOTO starte
IF EXIST destinationB
FOR /F "delims=\" %%I IN ('DIR "source directoryB" /B /O') DO SET NewestFile=%%I
echo Transferring...
xcopy "source directoryB\%NewestFile%" "destinationB" /s /c /d /e /r /y
echo Transfer complete
echo -------------------------
:startd
PING 1.1.1.1 -n 1 -w 1000 >NUL
IF EXIST destinationB GOTO startd
IF NOT EXIST destinationB GOTO starta

:starte
IF NOT EXIST destinationC GOTO startg
IF EXIST destinationC
FOR /F "delims=\" %%I IN ('DIR "source directoryC" /B /O') DO SET NewestFile=%%I
echo Transferring...
xcopy "source directoryC\%NewestFile%" "destinationC" /s /c /d /e /r /y
echo Transfer complete
echo -------------------------
:startf
PING 1.1.1.1 -n 1 -w 1000 >NUL
IF EXIST destinationC GOTO startf
IF NOT EXIST destinationC GOTO starta

:startg
IF NOT EXIST destinationD GOTO starta
IF EXIST destinationD
FOR /F "delims=\" %%I IN ('DIR "source directoryD" /B /O') DO SET NewestFile=%%I
echo Transferring...
xcopy "source directoryD\%NewestFile%" "destinationD" /s /c /d /e /r /y
echo Transfer complete
echo -------------------------
:starth
PING 1.1.1.1 -n 1 -w 1000 >NUL
IF EXIST destinationD GOTO starth
IF NOT EXIST destinationD GOTO starta
 
Back