photools.com Community

IMatch Discussion Boards => IMatch Scripting and Apps => Topic started by: Jingo on June 16, 2019, 07:34:15 PM

Title: APP: Clip Folders - create subfolders from clipboard string
Post by: Jingo on June 16, 2019, 07:34:15 PM
Hi All - Happy Father's Day!!  I threw together this app today for Menace based upon a request to parse a clipboard list and create subdirectories based upon the elements.  For example, if you paste in the following: Rötegewächse (Rubiaceae)\Labkräuter (Galium)\Galium  mollugo\ - then 3 nested subdirectories would get created:
   <base folder>
           \Rötegewächse (Rubiaceae)
                  \Labkräuter (Galium)
                         \Galium  mollugo

The App allows you to paste items into the keyboard using the Paste Button - this button will take what is in the clipboard, display the contents and parse the clipboard to determine subdirectories.  If you paste content that cannot be formatted into subdirs (ie: not in the proper <dir>\<dir> form), you can manually paste into the clipboard textarea box, edit the content into a single line with subdirs and then click the Update Dir List button to perform the parse again.  Remember to include that trailing "\" in order for the last subdir to be included!

Once you are satisfied, clicking the Create Folders button will let you choose the base folder location and then the subdirectories will get created.  If all goes well, the results box will detail what was created.

As always, please USE AT YOUR OWN RISK. While I did some basic testing on this, it has not been testing in detail and there is VERY LITTLE error checking going on...  always open to thoughts/suggestions!   To install, just unzip the attached file into your C:\ProgramData\photools.com\imatch6\webroot\user folder... it will appear automatically in the app manager.  The app works equally well inside IM as it does in the browser.

Enjoy!!

The FANCY Icon:
(https://www.photools.com/community/index.php?action=dlattach;topic=9118.0;attach=21856)

The APP Interface:
(https://www.photools.com/community/index.php?action=dlattach;topic=9118.0;attach=21858)

The Result Folder in Explorer (well... XYPlorer):
(https://www.photools.com/community/index.php?action=dlattach;topic=9118.0;attach=21854)
Title: Re: APP: Clip Folders - create subfolders from clipboard string
Post by: Menace on June 16, 2019, 07:41:51 PM
Hi Jingo, Happy Father's Day to you too (we don't have it here). :)

Wow, this is amazing. So fast and probably so helpful. Thank you very much.

But I have one Question? Where can I download it? It is just me, missing the zip?
Title: Re: APP: Clip Folders - create subfolders from clipboard string
Post by: Jingo on June 16, 2019, 07:48:50 PM
See.. I got too excited to share.. forgot the zip!  It has been attached now... Enjoy and I hope this is helpful to you! - Andy.
Title: Re: APP: Clip Folders - create subfolders from clipboard string
Post by: Menace on June 16, 2019, 08:05:41 PM
Yes, it is very helpful. Thank you a lot; I already create my first Subdirectories. :) And I absolutely admire you, how fast you create this App. I just look at your Code and I understand literally nothing.  ;D

Edit: I already changed my starting folder for my naturfotos and it works well.  :D
Title: Re: APP: Clip Folders - create subfolders from clipboard string
Post by: Jingo on June 16, 2019, 08:42:34 PM
Quote from: Menace on June 16, 2019, 08:05:41 PM
Yes, it is very helpful. Thank you a lot; I already create my first Subdirectories. :) And I absolutely admire you, how fast you create this App. I just look at your Code and I understand literally nothing.  ;D

Edit: I already changed my starting folder for my naturfotos and it works well.  :D

That's great.. so happy this is helpful.  A lot of thanks should go to Mario who created the ability for us to use easy coding languages like Javascript and UI Frameworks.   It has taken me a year or so to get familiar enough to code this quicky... the JS part comes quickly for me... the interaction with IM and the whole Asynch -> Promise stuff still takes me longer!

Have a great week!
Title: Re: APP: Clip Folders - create subfolders from clipboard string
Post by: Mario on June 16, 2019, 08:50:18 PM
Promises is the 'thing' because it enables you to keep the UI working while your app is waiting for IMatch or a web service. Quite simple, once you wrapped your head around it.

It's just the principle of "My code now calls this...which can take any amount of time...and when it is done, it calls this method" that many find confusing at first. Your program is no longer linear, in a sense.
but promises are easy to deal with, just then, fail and always to manage.

Web Workers is a concept that allows true multi-threading in apps. This will be exploited heavily, to utilize modern processors. Even small Notebooks now have four cores to use :-)

If you don't feel like using Promises, you can use aync/await. See https://www.photools.com/dev-center/doc/imatch/tutorial-recipes.html and search for await.
Title: Re: APP: Clip Folders - create subfolders from clipboard string
Post by: sinus on June 17, 2019, 08:14:48 AM
Quote from: Jingo on June 16, 2019, 07:48:50 PM
See.. I got too excited to share.. forgot the zip!  It has been attached now... Enjoy and I hope this is helpful to you! - Andy.

Hey Andy
thanks a lot for sharing a script!!! (and basically create it for Menace)
Though I have not to use it, because I create seldom new directories, it sounds cool.
And I envy your script-skills!  :D
Title: Re: APP: Clip Folders - create subfolders from clipboard string
Post by: Jingo on June 17, 2019, 01:28:04 PM
Quote from: sinus on June 17, 2019, 08:14:48 AM
editor (I'm still using Notepad++)

Don't. Thing of the past. Make your life easier. Use the free Visual Studio Code for a much better experience, proper syntax highlighting, linting etc. Highly recommended.
Title: Re: APP: Clip Folders - create subfolders from clipboard string
Post by: Menace on June 17, 2019, 01:57:56 PM
Congratulate to the 1000th posting.  :D

For me, JS seems not so easy, but I just started to watch some youtube-Videos.

In this App, I have a problem:

1. I paste the the Clipboard Text.
2. I change a little in the box of the Clipboard Test.
3. I click on "Update Dir List" -> Problem: It paste again the original Clipboard Text in the box and undo all my changes.

I solve the problem with the workaround:
1. Paste the Clipboard Text.
2. Change the Clipboard Text.
3. Copy again the Clipboard Text
4. Click the "Update Dir List"
5. Create folder
Title: Re: APP: Clip Folders - create subfolders from clipboard string
Post by: Jingo on June 17, 2019, 05:19:50 PM
Quote from: Menace on June 17, 2019, 01:57:56 PM
Congratulate to the 1000th posting.  :D

For me, JS seems not so easy, but I just started to watch some youtube-Videos.

In this App, I have a problem:

1. I paste the the Clipboard Text.
2. I change a little in the box of the Clipboard Test.
3. I click on "Update Dir List" -> Problem: It paste again the original Clipboard Text in the box and undo all my changes.

I solve the problem with the workaround:
1. Paste the Clipboard Text.
2. Change the Clipboard Text.
3. Copy again the Clipboard Text
4. Click the "Update Dir List"
5. Create folder

Whoops... that's what I get for trying to take a shortcut... nice bug find!  I just fixed this - here is an updated zip file.  If you want to fix this yourself without having to replace the file, just change one line in the index.html file - this will update the directory list from the current text box WITHOUT re-reading the clipboard contents:



old:

   $('#btn-update').click(function() {
           $('#btn-paste').click ();
   });


new:


   $('#btn-update').click(function() {
       parseDirs($('#cliptext').val());
   });
Title: Re: APP: Clip Folders - create subfolders from clipboard string
Post by: Menace on June 17, 2019, 05:43:40 PM
Thank you again for solving this issue so fast. :)

Title: Re: APP: Clip Folders - create subfolders from clipboard string
Post by: Jingo on June 17, 2019, 09:01:42 PM
My pleasure!!