How can I limit the extension allowed in a folder? - batch-file

I'm trying to create a folder which only allows certain types of file (.txt /.jpeg / etc...) I would like this operation to be automated via Windows task scheduler.
I'm already using the forFiles command to delete files older than a certain date.
Is there anything like this but that works on files extensions?
Edit, hoping it's more clear
I currently have a folder which I would like to limit the type of files that you can save on it, making it so ( in this case) that you can only place in it .txt files. The folder is in a Windows 2022 server. Having already uses windows task scheduler and forfiles to delete files older than a certain date, i was wandering if there was anything similar.
Thanks

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.

Overwrting multiple file using NSIS Script (how Win Zip extractor does)

I am writing a script using Null Script which install around 6000 files in INSTALLDIR i.e. C:\ABC folder.
I have done this using
File /r "ABC"
in install section.
It is just a simple extractor (no registry entries and no uninstall.exe created during install).
Now, if I run the same exe again then I want my exe to display a message box to the user while overwriting the files containing the options
Yes,
Yes too all, or
exit the installer
i.e. How WinZip software does while extracting the same zip file in the same location multiple times.
If I set the SetOverwrite value to off then during install (2nd time) my EXE just skips the file installation without notifying the user. Also using IFFILEEXIST I can check a single file or *.* files but cannot do one to one mapping.
Please suggest how can I implement this. If this question is already posted then please send me the link.
Thanks in advance.
It is not possible to get this behavior in NSIS when using File /r. You might be able to pull off something similar by generating the file list at compile time by executing a batch file with !system and then check if each file exists and maybe delete the old one at run-time but you are not going to get the dialog without a custom plugin. NSIS itself only supports basic Abort/Retry/Cancel and Yes/No dialogs.
If you only want to use free tools, why not just use 7-Zip to create a self extracting archive?

Windows CE7 | Move and replace directory from the command prompt

I'm trying to write a batch file that should copy a directory from a USB stick and place it in another folder on the hard disk (if the folder already exists, the new one should replace it).
Currently I'm trying something like this:
COPY "\Hard Disk2\sourceFolder" "\Hard Disk\targetFolder"
which doesn't copy any the "sourceFolder" or any subfolders.
I want to move everything (including folders) from my sourceFolder to my targetFolder.
Anyone knows how to do this?
For a list of available commands in Windows CE 7, please see this picture.
More information about the commands: https://msdn.microsoft.com/en-us/library/ee505427(v=winembedded.60).aspx
Note:
I don't think XCOPY or ROBOCOPY works in CE. I've tried both, but I just get the following error:
"Cannot execute ROBOCOPY.exe / XCOPY.exe".
The Command prompt for Windows Embedded Compact 7 is very limited and is not intend to be used on a final product, but as a tool for the firmware development and tuning. So the option that you are looking is not available and therefore, you will probably have to develop your own version of the XCopy command.

It's possible to make a Batch program that backup a folder files from my external hd to pc hdd, anytime I add or change a file?

I'm a graphic designer and I use my external hd frequently to move psd/jpeg/png/tiff files from my laptop at home to my Work PC and vice versa. But as a precaution before modifying or adding a file I copy it to a folder. It's possible to make it automatically? And it's easy to make on Batch?
Thanks for help!
Robocopy is your friend; google it and have a look. It's a very powerful program by sysinternals (owned by Microsoft). Alternatively, if you want a nice GUI to go with it use SyncToy (https://www.microsoft.com/en-gb/download/details.aspx?id=15155) which can be run with a batch file (including arguments) or made into a scheduled task.

Sync folders with xcopy/batch based on checksum?

I'm trying to make a simple batch for windows that will basically sync two folders, the catch is that the files in the folders can be named arbitrarily and the snyc should be based on the checksum. I've only found information about xcopy that compares the timestamp so I'm wondering if this is possible in a simple matter at all.
Here is the scenario I'm trying to manage, you've got the "Import Folder" containing the files named A_2.bmp and A_3.bmp and the "Target Folder" containing file A_1.bmp.
File A_2.bmp is infact the same file as A_1.bmp, just with a different name and thus should be skipped, A_3.bmp should then be copied over to target folder and icrementally renamed to A_2.bmp.
This probably sounds more like a work for patching software, but I'm looking for a solution that doesn't require building patches all the time and is open for the user (so he can just drop files into the import folder and run it whenever the need arises)
If there is software for such a thing that is free and can be distributed without installing I would also consider this a good option, but I haven't found anything.
I'm thankful for any advice and help on this matter so thank you very much for your time and help!
You have this command line utility :
http://www.microsoft.com/en-us/download/details.aspx?id=11533
You can then make a bat who simply test the checksum of the files

Resources