Copy files automatically from usb to specific folder with specific extensions - loops

I have huge amount of flash drives and I need to backup my files on specific folder (for example C:\Backup).
There are two problems :
1. I need to backup files with .doc and .docx extension only.
2. When flash drive is inserted, I want that files would copy automatically.
(It's loop if I remember)
Is there any batch solution for this?

try this tutorial for autoplay USB
Then, i am thinking, instead of the autoplay.exe you can set it to run a batch file instead.
In that batch file use the xcopy command.

Related

Batch Programming - Not deleting partial files being written

I am trying to develop a batch script which copies a list of files from the a source directory to another directory and does some functions. Once the copy has been done, the files needs to be deleted from the source directory.
In the source directory, we are receiving files on real time basis 24x7 from an external source.
How can I make sure, the copy or the delete from the script does not impact any files which are currently being sent (incomplete files which are in relay at that moment) from the external source in the source directory, whilst the script is doing its own job?
The script needs to be ran every 5 minutes.
Due to some challenges, we cannot xxcopy for our functionality.
Please can you advise.
Instead of COPY& DELETE use MOVE, so the batch fragment would look like this:
FOR %%F IN (C:\SOURCE\*.*) DO MOVE %%F C:\TARGET\
If file in incomplete (other process uses it), then MOVE on that file will fail. Next time the script is run, it will attempt to move that file again.

Efficiently Download Newer files via FTP (Large amount of files with WinSCP commandline)

I am currently creating a small process that will download any new or updated file from an FTP(not SFTP) location to a local drive. I have written a small batch script along with WinSCP, but it takes FAR too long. There are around 200k files and 16k folders on the FTP. It takes just under an hour to check every file and folder, not including any time downloading any new/updated file. From what I understand, WinSCP compared file modification dates of every single file and folder, which is why it takes so long. I'm not sure where to go from here.
I am using WINDOWS 10.
Is there a better way to go about synchronizing these? Possibly check FTP drive if anything has been changed, if so, find the change and download it? Will post pics of batch if needed.
Thank you!

.bat file to open a specific folder and copy files from a usb drive

I am having difficulties with creating a simple batch file.
What I would like is a batch file that will open up a specific directory and copy 2 files from the same directory that the batch file is in and paste them in the directory that was just opened.
So, in this instance, I have a USB flash drive. I have two IE shortcuts that I would like copied and placed in a public desktop.
The .bat file and the 2 files will all be on the root of the flash drive.
So, my understanding is that it should look like this (EWQ is the IE shortcut and keyfinder is just a test file because i wasn't sure on the extensions... i could not figure out what the IE shortcut extension would be as I don't think it has one):
%SystemRoot%\explorer.exe C:\Users\Public\Desktop<br>
copy EWQ C:\Users\Public\Desktop<br>
copy keyfinder.cfg C:\Users\Public\Desktop
I get my public desktop folder to open but nothing copies. I have
tried various prefixes, like "%~dp0\EWQ" (with an without the quotes)
but to no avail.
These will be loaded from a flash drive and I have about 500 to do so I'd like this as quick and possible. Basically, pop in the flash drive, double click the .bat file and yank it out. In theory, it 'should' be the same drive letter every time, but that isn't guaranteed.
Thank you for any help!!!
This is a batch file, let's call it testing.cmd.
#Copy "%~d0\EWQ.url" "%PUBLIC%\Desktop"
#Copy "%~d0\keyfinder.cfg" "%PUBLIC%\Desktop"
Place this file somewhere on your flash drive and double click it, ensuring that both EWQ.url and keyfinder.cfg are in the root of that drive. If you do not have access to the destination you could try by right clicking testing.cmd and choosing Run as administrator.

Open a .bat file, out of a folder, off a flashdrive

I have a game that I'm making off of my flashdrive, and I'm trying to make a save feature into an RPG game. I know I can just save all the data into a character bat file, and then call that bat file, but the problem is that my flashdrive looks cluttered whenever multiple characters get formed. understand? I need to beable to load a save, from a character folder (for organization) from a changing source folder, (Because the flashdrive will be in different USB ports, such as :E or :F etc.)
You can determine the drive that a Windows batch file uses by using the CMD variable substitutions. Within a batch file, you can determine where the file resides.
%~d0 is the drive. %~dp0 is the directory. And there are more.
See What does %~dp0 mean, and how does it work?

batch script to find a particular folder in a drive

am a newbie to the batch script, i have many folders called LIB in my drive
say it can be as LIB_data,lib,lib_ac anything that starts with lib or LIB... i want to list all these directories and sort them in which they have created in the pc and copy the latest directory contents to BATCH_LATEST_LIB_FILES folder,that will be a new folder created by this batch file.i want this new folder to be created in the path where this batch file is present. please help me with a batch script.
You might look at FOR, DATE, TIME, SORT, IF, GOTO and XCOPY.
This site is a great resource for batch files.

Resources