hjf

Tuesday, February 10, 2015

Collector V1.1

Collector (V1.1 - Updated)

Like most people I am constantly downloading files and installing software to my computer and because, like most people, I am busy all the time I don't have as much time as I would like to keep my system clean and so I like to write scripts to automate as much as I can to give me more free time away from my computer.

Over the years after cleaning, optimizing and fixing countless computers I have learned that most files that eat up disk space that can comfortably be removed are usually media and installation files; things you download from the internet pretty much. Lots of archived files like zips, rars etc... can end up taking up lots of space and even the most organized of us end up having files spread throughout our system and half the time we forget about them.

Recently I wrote a script (Collector V1.1) to copy all files of specific passed extension types to a folder on the desktop so that I can easily analyze the total file size of all said files. Doing this I also found files I forgot I even had and files I knew could be deleted I found the source files and deleted. I have converted my script to exe for easy portability and an administrative manifest.

Collector V1.1 is a command line utility (cli/clu) used by passing file extensions to it via a command line such as MS-DOS CMD.
E.g.:
collect.exe pdf txt log
will search your whole computer for all files with those extensions and then copy them to individual folders inside of a folder on your desktop named "Collection". There is no limit to the amount of passed extensions as it shifts each to %1 until [%1]==[].


Note: As with all bat to exe conversions this might come up as a false positive in your AV, just exclude in your AV. The collect.exe file must be placed in a folder that can be read from %PATH% such as C:\Windows\System32 or if you've added your own custom paths. You can also just cd to the path of your stored collect.exe.

Version Info:

  • Version 1.0 - Initial release. No known bugs.
  • Version 1.1 - Add log file with locations of original files.

Download:

Original Code:


@echo off
set "backd=%cd%"
title Collect Files
cls

:loop
mode 78,4
if [%1]==[] (
call :err
if exist "%mainf%" start "" explorer "%mainf%"
goto :eof
)

set "efile=%1"
set "mainf=%userprofile%\Desktop\Collection\"
set "wdir=%mainf%%efile%\"

cd C:\
echo(
echo Copying all "%efile%" files to %wdir%
echo(
for /r %%i in (*.%efile%) do (xcopy "%%i" "%wdir%" /q /y) >nul 2>nul
cls
cd %backd%
shift
goto :loop

:err
color FC
mode 38,4
cls
echo(
echo No more files to process...
echo(
pause
cls
color 0F
mode 80,25
title %backd%
exit /b

collector

No comments: