Hack Forums
[Shell] Desktop Organizer - Reloaded 2016 - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Shell] Desktop Organizer - Reloaded 2016 (/showthread.php?tid=5358403)



Desktop Organizer - Reloaded 2016 - Ventriloquism - Jul 31, 2016

[Image: 9Zlkno4.png]


Hello. I was goofing around a week or two ago, and never got a chance to post this, but I feel like I should. A little over a year ago, I made a Desktop Organizer. Looking back on the code, it was very pitiful. But now, my batch skills have gotten better, and I decided to make a reloaded version. This time it is way more efficient, and uses a significant less amount of lines than the first one did. The original project can be found here 😖
Code
@echo off >Nul
Set "droppath=%userprofile%\Desktop"
For %%a In (.txt, .png, .mp3, .docx, .bat) Do (For %%b In (%%a) Do (
      If exist "%droppath%\*%%a" Mkdir %%a
      Move "%droppath%\*%%b" %path%\%%a
  )
)
pause >nul
@exit /B
As you can see, the %path% variable is set to the desktop. This can be changed to organize any folder you'd like. I probably should have changed the name to "folder organizer" but by default, it is set to organize the most used part of your machine. Feel free to add to this code or do whatever.


* - K3njii - Jul 31, 2016

Nice thread man!
Although I keep my Desktop organized and probably won't find this useful, I see this being helpful for many other users.


* - granz - Jul 31, 2016

Thanks for this, will come handy as i have a desktop which makes me fucking dizzy.


* - Anisty - Jul 31, 2016

Nice share man 🤝


* - Ventriloquism - Jul 31, 2016

Thank you guys for your feedback 🤝 Lmk if there is anything I should add.


* - ImDeepWithWindows - Jul 31, 2016

(Jul 31, 2016 05:01 AM)Ventriloquism Wrote:  Hello. I was goofing around a week or two ago, and never got a chance to post this, but I feel like I should. A little over a year ago, I made a Desktop Organizer. Looking back on the code, it was very pitiful. But now, my batch skills have gotten better, and I decided to make a reloaded version. This time it is way more efficient, and uses a significant less amount of lines than the first one did. The original project can be found here 😖
Code
@echo off >Nul
Set "path=%userprofile%\Desktop"
For %%a In (.txt, .png, .mp3, docx, .bat) Do (For %%b In (%%a) Do (
      If exist "%path%\*%%a" Mkdir %%a
      Move "%path%\*%%b" %path%\%%a
  )
)
pause >nul
@exit /B
As you can see, the %path% variable is set to the desktop. This can be changed to organize any folder you'd like. I probably should have changed the name to "folder organizer" but by default, it is set to organize the most used part of your machine. Feel free to add to this code or do whatever.

i like the idea i like the syntax, good job

one thing though, just because of what the environment variable "path" is and how significant that is and bad it would be if it got globally changed not just changed within this batch-file's running session it even though it wont be it might be better to use
Code
cd  /d "%userprofile%\desktop"
than
Code
Set "path=%userprofile%\Desktop"
just out of good habit




good job,
this would definitely simplify my desktop lol


* - Ventriloquism - Jul 31, 2016

(Jul 31, 2016 06:43 PM)ImDeepWithWindows Wrote:  just out of good habit

I'm not sure what you are trying to tell me. Are you saying if the current disk were to change or something?

Sorry, I'm incredibly exhausted 🤮


* - JoshuTee - Aug 31, 2016

Hi, may I use this amazing little script in one of my scripts? I will give you credit of course!


* - ɩᴄᴀʀᴜȿ ᴌוᴠᴇѕ™ - Aug 31, 2016

(Jul 31, 2016 06:43 PM)ImDeepWithWindows Wrote:  i like the idea i like the syntax, good job

one thing though, just because of what the environment variable "path" is and how significant that is and bad it would be if it got globally changed not just changed within this batch-file's running session it even though it wont be it might be better to use
Code
cd  /d "%userprofile%\desktop"
than
Code
Set "path=%userprofile%\Desktop"
just out of good habit




good job,
this would definitely simplify my desktop lol

(Jul 31, 2016 06:50 PM)Ventriloquism Wrote:  I'm not sure what you are trying to tell me. Are you saying if the current disk were to change or something?

Sorry, I'm incredibly exhausted 🤮

What he means is that %PATH% is a globally default variable already. Open CMD and type echo %path%.

It would be wise to NOT overwrite preexisting default variables.


* - ๖ۣۜOpulence - Aug 31, 2016

I spy a potential issue, you forgot to put '.docx' meaning if a file was docx.exe it would still be sorted with the .docx files... Please correct me if I'm wrong..

Thanks for the share OP!


* - Ventriloquism - Aug 31, 2016

(Aug 31, 2016 01:32 PM)๖ۣۜOpulence Wrote:  I spy a potential issue, you forgot to put '.docx' meaning if a file was docx.exe it would still be sorted with the .docx files... Please correct me if I'm wrong..

Thanks for the share OP!

No, you're right lol. I forgot the period at the beginning. I'll fix it 😝

@Icarus I didn't know that. I'll change that was well.


* - ︻デ┳═ー - Sep 1, 2016

Awesome! This is definitely something I am going to try out :D
Keep up the good work.