Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Shell 

Desktop Organizer

Short but sweet code, drag and drop a mess of programs and the code organizes the programs by their extensions.
Code
@echo off & setlocal EnableDelayedExpansion
for %%A in (%*) do (
set /a x+=1
set prog!x!=%%A
set progext!x!=%%~xA
)
for /l %%A in (1,1,!x!) do (
if "!progext%%A!"=="" set progext%%A=Folders
if not exist "%cd%\!progext%%A!" md "%cd%\!progext%%A!"
for /l %%B in (%%A,1,!x!) do (
if exist "!prog%%B!" if "!progext%%A!"=="!progext%%B!" move !prog%%B! !progext%%A!
))
cls & echo Finished. Cleaned !x! Programs up.
Pause > nul
Merry Christmas 🤝
Just taking a quick glance through it, I've got a small suggestion. You should take a look at using a standard FOR loop (no extra switches) to loop over %* It has all the arguments already, so you don't need to shift for each one.
(Dec 23, 2015 10:44 PM)White Light Wrote:  Just taking a quick glance through it, I've got a small suggestion. You should take a look at using a standard FOR loop (no extra switches) to loop over %* It has all the arguments already, so you don't need to shift for each one.
I'll look into it in the morning, way too tired to function right now


I've been trying to use the standard for loop but I keep getting errors when I try to loop through the extensions
Code
for %%A in (%~x*) do set /a "y+=1" & set "progext!x!=%%A"
but when I do(below) it works, keep in mind I need to grab the extension since the program organizes based off the extension.
Code
for %%A in (%*) do set /a "x+=1" & set "prog!x!=%%A"
can someone point out my mistake?
As far as I can tell, you need to loop through %*, not %~x*, and from there you would do %%~xA...

Ex:
Code
FOR %%G IN (%*) DO (
  ECHO %%~xG
)
Getting Started: C/C++
[C/C++/.NET/x86 ASM - Automation Programmer]
(Dec 23, 2015 11:00 PM)wurd Wrote:  I'll look into it in the morning, way too tired to function right now


I've been trying to use the standard for loop but I keep getting errors when I try to loop through the extensions
Code
for %%A in (%~x*) do set /a "y+=1" & set "progext!x!=%%A"
but when I do(below) it works, keep in mind I need to grab the extension since the program organizes based off the extension.
Code
for %%A in (%*) do set /a "x+=1" & set "prog!x!=%%A"
can someone point out my mistake?


As 0xDEAD10CC said, you should loop through %* and then use the x modifier on each individual result. There's no way for the script to natively use modifiers on %* without first parsing through the individual parameters.
Fixed. Thanks for the help guys
I'm new to coding can you tell me exactly what this is suppost to do? i ran it and it said applications cleaned so i guess it work

-stamina
(Jan 2, 2016 12:58 PM)Stamina_Client Wrote:  I'm new to coding can you tell me exactly what this is suppost to do? i ran it and it said applications cleaned so i guess it work

-stamina

it organizes them by filetype, so all like filetypes are grouped up.
(Jan 2, 2016 12:58 PM)Stamina_Client Wrote:  I'm new to coding can you tell me exactly what this is suppost to do? i ran it and it said applications cleaned so i guess it work
-stamina
Click and drag the programs you want to be cleaned onto the batch file
[Image: 864908bd079cae5e1e969fdca95b7a75.gif]

Contact me @ [email protected]

you should mabey add a for loop to this
(Jan 4, 2016 05:06 PM)wurd Wrote:  Click and drag the programs you want to be cleaned onto the batch file
[Image: 864908bd079cae5e1e969fdca95b7a75.gif]

Awesome demo gif. :> Very good to show people how it works!


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by fisica638Sep 3, 2020 01:44 PM 6 221 Sep 3, 2020 01:44 PM
Last Post: IGK4L
[Shell] by VentriloquismSep 1, 2016 09:54 AM 11 631 Sep 1, 2016 09:54 AM
Last Post: ︻デ┳═ー
[Python] by Tripo5Jun 17, 2016 10:45 AM 7 387 Jun 17, 2016 10:45 AM
Last Post: Tripo5