|
nkormanik
|
 |
« on: June 15, 2012, 07:12:26 PM » |
|
I've encountered a new need hopefully one of you can help with: Given: One folder full of large-sized image files, around 15,000 files in all. Called IMAGE FOLDER. Task: -- Create another folder outside of IMAGE FOLDER with name XXX01 FOLDER. -- For any images in IMAGE FOLDER whose name has "XXX01" in it, create a shortcut within XXX01 FOLDER to those images. -- Create another folder outside of IMAGE FOLDER with name XXX02 FOLDER. -- For any images in IMAGE FOLDER whose name has "XXX02" in it, create a shortcut within XXX02 FOLDER to those images. -- Create another folder outside of IMAGE FOLDER with name XXX03 FOLDER. -- For any images in IMAGE FOLDER whose name has "XXX03" in it, create a shortcut within XXX03 FOLDER to those images. etc. In total there will be 180 of these shortcut folders needing to be created. Each of these shortcut folders will have around 180 shortcuts in it. Challenge: Write program that does the above automatically. Input --- folder in which to search. Input --- what exactly to look for. Input --- list of new folders to create. Go! Thanks to all of you. Nicholas Kormanik nkormanik@gmail.com
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #1 on: June 15, 2012, 07:18:14 PM » |
|
I could add another output method to my File Punter application and it should do what you want. You'd have to use a little bit of RegEx but that's not so hard. =]
|
|
|
|
|
Logged
|
|
|
|
|
nkormanik
|
 |
« Reply #2 on: June 15, 2012, 07:31:27 PM » |
|
What a saint!! Just please guide on the RegEx, as sometimes it's a bit tricky.
Is the explanation of what I'm trying to do clear enough?
Creating the shortcuts in the folders is my attempt not to have to copy the image files themselves over and over and over again into the various folders.
The names of the image files include at least two of the searched-for snippets.
Example: XXXX32_XXXX79.png
Thanks so much!
Hope this will be useful to others as well.
|
|
|
|
|
Logged
|
|
|
|
|
|
skwire
|
 |
« Reply #3 on: June 15, 2012, 07:35:47 PM » |
|
So, given this filename: XXXX32_XXXX79.png
What do you want to match on?
If you could provide me, in a PM or something, a sample list of the actual filenames (and subsequent matches), that would be most helpful for testing. Feel free to look up my profile and contact me via any of the instant messengers there.
|
|
|
|
|
Logged
|
|
|
|
|
nkormanik
|
 |
« Reply #4 on: June 15, 2012, 07:55:42 PM » |
|
Given the filename XXXX32_XXXX79.png....
I will be matching on two snippets, if manually in two different steps.
First I'll be matching on "XXXX32". Creating a folder XXXX32. And putting a shortcut to the file XXXX32_XXXX79.png within that folder.
Then I'll be matching on "XXXX79". Creating a folder XXXX79. And putting a shortcut to the file XXXX32_XXXX79.png within that folder.
As background to what I'm attempting to accomplish:
The image files are 'contour plots' of the two variables, in the present case variables 32 and 79.
Within XXX32 folder, there will be shortcuts to all the contour plots which variable 32 plays a part.
So, in XXX32, there will be shortcuts to the following image files:
XXXX32_XXXX01.png XXXX32_XXXX02.png XXXX32_XXXX03.png XXXX32_XXXX04.png . . . XXXX32_XXXX180.png
Having all the variable 32 shortcuts in one folder -- XXX32 -- would allow me to focus on just those images at one time.
Then I could move on to the variable 33 folder -- XXX33 -- for instance, and look at just the images where variable 33 plays a part.
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #5 on: June 15, 2012, 10:22:10 PM » |
|
Give this a try: File Punter v1.0.4.21) Download, unzip, and launch FilePunter. 2) Click the green plus button and create two rules like this (obviously, change the paths to accommodate your system): First rule - Choose the correct source folder.
- Leave the Recurse source folder checkbox unchecked.
- Pattern: (.*)_
- Check the Pattern is a regular expression checkbox.
- Destination: c:\path\to\destination_1\??1

Second rule - Choose the correct source folder.
- Leave the Recurse source folder checkbox unchecked.
- Pattern: _(.*)\.
- Check the Pattern is a regular expression checkbox.
- Destination: c:\path\to\destination_2\??1

It should look something like this when you're done: 3) Check each of the rows. 4) Change the method dropdown to Create shortcuts. 5) Click the Start button. Let us know if you have great success or epic failure. 
|
|
|
|
« Last Edit: June 16, 2012, 12:29:03 PM by skwire »
|
Logged
|
|
|
|
|
nkormanik
|
 |
« Reply #6 on: June 16, 2012, 01:27:19 AM » |
|
Thanks, Skwire, for adding the "Create Shortcuts" option. I think that's exactly what's needed. Thanks, too, for the clear instructions.
I'm still somewhat unclear on regular expressions, but will experiment and continue learning.
Hope this has been helpful for others as well.
|
|
|
|
|
Logged
|
|
|
|
|
nkormanik
|
 |
« Reply #7 on: June 16, 2012, 01:58:39 AM » |
|
This feedback may better belong in the File Punter thread. But..., I tried the new "Create Shortcuts" option using plain wildcards, and no shortcuts were produced in the destination folder.
"Copy files to destination" worked fine.
"Simulation only" worked fine.
code used:
C:\Downloads *.jpg C:\4 No No
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #8 on: June 16, 2012, 12:26:11 PM » |
|
I tried the new "Create Shortcuts" option using plain wildcards, and no shortcuts were produced in the destination folder.
Yep, I hadn't added it to that portion of the application. It should function in this build: File Punter v1.0.4.3Please let me know if the app functions how you like. If so, I'll promote it to v1.0.5 and release it on my main site. Thanks for testing. =]
|
|
|
|
|
Logged
|
|
|
|
|
nkormanik
|
 |
« Reply #9 on: June 16, 2012, 05:05:56 PM » |
|
Bingo!
Amazing program, Skwire.
Really nice touch, too, that the destination folders need not actually exist, but will be automatically created. That is an extremely important feature.
Seems, in answer to my original request, that using plain wild cards alone will do the trick using your program. User just needs to create a text file containing the snippets one per line. And import that text file into File Punter. Press start.
I suppose using Regular Expressions, though, would be more efficient. Trouble is, I have yet to figure out RegEx....
Fantastic job! Thanks a million.
|
|
|
|
|
Logged
|
|
|
|
|
nkormanik
|
 |
« Reply #10 on: June 16, 2012, 05:15:11 PM » |
|
One additional little feature you could add would be a button to "Select All" -- instead of user having to click in every single box.
Say, if user imports a text file of 200 lines, so that 200 check boxes would need to be manually clicked on.
Better to have a "Select All" or "Check All" button.
Maybe a "Check None" as well.
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #11 on: June 16, 2012, 05:35:16 PM » |
|
There are check/uncheck buttons in the toolbar that should do what you want. 
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #12 on: June 16, 2012, 07:59:27 PM » |
|
Seems, in answer to my original request, that using plain wild cards alone will do the trick using your program. User just needs to create a text file containing the snippets one per line. And import that text file into File Punter. Press start.
Say, if user imports a text file of 200 lines, so that 200 check boxes would need to be manually clicked on.
Hmmm...are you creating 200 separate rules for your use? If so, maybe we can help out with a RegEx that will do what you need? Did the RegEx I provided earlier work for you?
|
|
|
|
|
Logged
|
|
|
|
|
nkormanik
|
 |
« Reply #13 on: June 16, 2012, 11:55:05 PM » |
|
I haven't created the actual files yet. Was planning ahead. Figuring that, of course, it would take any programmer a week or so to come up with something. That is, if they could at all.
I didn't figure on Skwire completing the task in a few hours....
However, I do have a list of the files that should result. Here is a partial list:
50501_20104_21901.png 50501_20104_21902.png 50501_20104_21903.png 50501_20104_22001.png 50501_20104_22002.png 50501_20104_22003.png 50501_20104_22004.png 50501_20104_22005.png 50501_20104_22006.png 50501_20104_22101.png 50501_20104_22102.png 50501_20104_22103.png
There will be 16,110 of these image files. Let's assume that all these image files are held in the folder:
c:\contour plot images\
Pairing up the second and third sections of each file name -- these two variables are the x and y in a contour plot.
The first section of the file name, 50501 here, is the z variable in the contour plot.
It's the second and third sections of each file name that I want to focus on in providing shortcuts.
There are a total of 180 variables in the second and third name-section combinations.
So the task, for instance, if 20104 is mentioned in the filename, create subdirectory 20104, and make a shortcut in that folder to the image file which contains its name:
c:\contour plot shortcuts\20104\50501_20104_21901.png.lnk (i.e., a shortcut) etc.
In the 21901 folder will appear the exact same shortcut, because 21901 is mentioned in the filename:
c:\contour plot shortcuts\21901\50501_20104_21901.png.lnk (i.e., a shortcut) etc.
There will be 180 shortcut folders. And 180 shortcuts in each folder. (Maybe 179, actually.)
Using File Punter..., 180 lines of commands, one for each of the variables.
c:\contour plot images\ *20104* c:\contour plot shortcuts\20104 No No c:\contour plot images\ *21901* c:\contour plot shortcuts\21901 No No etc.
Pretty straight forward.
Only issue will be getting tabs between the component parts of the commands in the text file which will be imported by File Punter. I'm assuming that tabs as delimiters are indeed needed (as opposed to spaces). Please mention if that's not the case. I think it would have to be, because of spaces being in the file path. Hmmm. What's the easiest way to get tabs between the component parts?
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #14 on: June 17, 2012, 12:04:37 AM » |
|
Using File Punter..., 180 lines of commands, one for each of the variables. No need for 180 rules; you can do this in two rules using Regular Expressions. Follow the same instructions as in my previous post but change the patterns to the following: First rule pattern: .*_(.*)_Second rule pattern: .*_(.*)\.Those two rules should accomplish what you want. =]
|
|
|
|
|
Logged
|
|
|
|
|
nkormanik
|
 |
« Reply #15 on: June 17, 2012, 12:26:05 AM » |
|
Wow!
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #16 on: June 17, 2012, 01:24:52 PM » |
|
Did you give those rules a try and, if so, did they work as you wanted?
|
|
|
|
|
Logged
|
|
|
|
|
nkormanik
|
 |
« Reply #17 on: June 17, 2012, 05:27:38 PM » |
|
It'll take a few days to create the actual image files. For now I've created 'dummy' image files, to test.
So, in the following subdirectory are 16110 files:
c:\images\
Partial list of those files:
50501_20104_21901.png 50501_20104_21902.png 50501_20104_21903.png 50501_20104_22001.png 50501_20104_22002.png 50501_20104_22003.png etc.
I've created an empty subdirectory in which to hold the shortcuts File Punter will create:
c:\shortcuts\
I've set up File Punter as follows:
C:\Images .*_(.*)_ C:\Shortcuts No Yes C:\Images .*_(.*)\. C:\Shortcuts No Yes
I haven't tried running yet, because I'd like assistance on the "Destination." Above in this thread you said to use the following:
Destination: c:\path\to\destination_1\??1 Destination: c:\path\to\destination_2\??1
Please change your instructions for the actual case at hand. I'm not following what exactly to do regarding "Destination."
End result should be:
c:\shortcuts\20104\50501_20104_21901.png.lnk (i.e., a shortcut) etc.
c:\shortcuts\21901\50501_20104_21901.png.lnk (i.e., a shortcut) etc.
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #18 on: June 17, 2012, 05:45:25 PM » |
|
I've set up File Punter as follows:
C:\Images .*_(.*)_ C:\Shortcuts No Yes C:\Images .*_(.*)\. C:\Shortcuts No Yes The way you have it should work perfectly. 
|
|
|
|
|
Logged
|
|
|
|
|
nkormanik
|
 |
« Reply #19 on: June 17, 2012, 06:12:05 PM » |
|
Okay, just tried it, the way I have it above. File Punter created the shortcuts. But put all the shortcuts into one subdirectory:
c:\shortcuts\
All 16110 of 'em.
So, it appears that the "Destination" will have to be changed from what I have, in order to create the separate folders per filename section within c:\shortcuts\.
By the way, nice touch that File Punter remembers the previous setup, and populates the order on that.
Also..., going to put up another program request: Folder Properties Auto-Update....
|
|
|
|
|
Logged
|
|
|
|
|
skwire
|
 |
« Reply #20 on: June 17, 2012, 06:35:05 PM » |
|
Okay, just tried it, the way I have it above. File Punter created the shortcuts. But put all the shortcuts into one subdirectory:
c:\shortcuts\ Ah, crap, my fault. Make your destinations for each of those two rules like this: c:\Shortcuts\??1 After doing that, try it again and let me know. Apologies. 
|
|
|
|
|
Logged
|
|
|
|
|
nkormanik
|
 |
« Reply #21 on: June 18, 2012, 03:46:34 AM » |
|
Okay, Skwire, worked just as you said it would.
I also tried the regular wild card route, and that worked fine as well.
One possible enhancement, but not a big deal, would be some sort of 'status line' at bottom of program window saying how many items were checked.
For instance, using the regular wild card route, I had 180 lines. Would be good to see "Checked Items = 180" or some such.
Not a biggie, though.
Thanks for all the work on this project. I greatly appreciate it.
|
|
|
|
|
Logged
|
|
|
|
|
|
|