Moving pictures and videos within Sub-folders

Is there a way for DO to perform two processes:

1.I have new daily sub-folders and within those sub-folders I wish to organize all pictures and videos by doing the following: moving all pictures types into a folder created by a "Modified Year" date?. For example, In a subdirectory "LeonardB", I can move .jpg, .png, etc. going into a folder called 2012 (current year) and any and all videos going into a "V" folder regardless of date. I currently use DropIt to perform such tasks but would be nice if DO could do the same.

It would make our life so much easier to manage our digital family albums using DO only.

(Before)
folder:LeonardB
Files:Leonard.jpg (01-01-12), Leonard1.png (03-01-12), Leonard3.jpg (01-01-11), Leonard.avi

(After)
folder: LeonardB
sub-folder:2012 (created by the Modified Year date)
Files: Leonard.jpg, Leonard1.png
sub-folder: 2011 (created by the Modified Year date)
Files: Leonard3.jpg
sub-folder: V
File: Leonard.avi

  1. If yes, Could DO actually monitor a specific parent directory that may have new daily sub-folders at any given time so the above process can be performed automatically. Of course DropIt can perform the same task but would be nice to use my powerful File Management tool to perform it instead.

I have to note that I'm not at all a programmer so I can't even begin to understand how I can do this.

Any help would be greatly appreciated.

#1 is possible using the rename tool in Opus. If you link your account I'll work out the exact way to do the example you gave for you.

#2 Opus won't run things automatically like that, but if you get #1 working then you could configure DropIt to trigger the Opus command automatically, or just have the command on a button or hotkey so you can quickly and easily trigger it on demand.

Hi Leo, I have linked my account.

Thanks.

Using a script seemed the best way to tackle this.

Here it is in the Rename dialog, just to show what it does:


I've also highlighted the line where it decides if a file is a video or not. You may need to add some file extensions there if it doesn't have all the ones you use.

And here it is in button form:

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" separate="yes" textcol="none">
	<label>Organise Daily</label>
	<icon1>#move</icon1>
	<function type="normal">
		<instruction>Rename FROM * TO * TYPE=files </instruction>
		<instruction>@script vbscript</instruction>
		<instruction>option explicit</instruction>
		<instruction />
		<instruction>Dim fs</instruction>
		<instruction>Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot;)</instruction>
		<instruction />
		<instruction>Function Rename_GetNewName ( strFileName, strFullPath, fIsFolder, strOldName, ByRef strNewName )</instruction>
		<instruction />
		<instruction>	Dim strExtension</instruction>
		<instruction>	Dim fileObj</instruction>
		<instruction />
		<instruction>	If (fIsFolder OR 0 = InStr(strFileName,&quot;.&quot;)) Then</instruction>
		<instruction>		Exit Function &apos; Don&apos;t do anything to folders, or files without extensions.</instruction>
		<instruction>	End If</instruction>
		<instruction />
		<instruction>	strExtension = Right(strFileName, Len(strFileName)-(InStrRev(strFileName,&quot;.&quot;)-1))</instruction>
		<instruction />
		<instruction>	If (strExtension = &quot;.avi&quot; OR strExtension = &quot;.mpg&quot; OR strExtension = &quot;.mkv&quot;) Then</instruction>
		<instruction>		strNewName = &quot;V\&quot; &amp; strFileName</instruction>
		<instruction>	Else</instruction>
		<instruction>		Set fileObj = fs.GetFile(strFullPath &amp; &quot;\&quot; &amp; strFileName)</instruction>
		<instruction>		strNewName = Year(fileObj.DateLastModified) &amp; &quot;\&quot; &amp; strFileName</instruction>
		<instruction>	End If</instruction>
		<instruction>								</instruction>
		<instruction>End Function</instruction>
	</function>
</button>

Paste that to your toolbar and you'll then have a button you can click which moves all files below the current directory into either a V subdirectory (for videos) or a subdirectory for the year in their modified timestamps.

Note that the button runs on all files below the current directory, whether they are selected or not. You can change that if you want, but I figured it would save a step. Of course, be careful not to click the button by mistake in some other directory!

If you edit the button after pasting it on your toolbar, you'll find a field where you can give it a hotkey if you want.

Thank you Leo, it does exactly the function as designed. I was quite surprised that DO performed this task much faster than DropIt too.

We may at times have several folders that contain pictures, etc. and DropIt allows us to also highlight those folders and perform the same function. Can this script be slightly changed (I have no clue on how) so that we can also select folders (versus run all files below the current directory) to perform that same function?

This seems to work for each selected folder (only doing the files immediately below them):

<?xml version="1.0"?>
<button backcol="none" display="both" label_pos="right" separate="yes" textcol="none">
	<label>Organise Daily</label>
	<icon1>#move</icon1>
	<function type="normal">
		<instruction>Rename FROM {filepath}* TO * TYPE=files </instruction>
		<instruction>@script vbscript</instruction>
		<instruction>option explicit</instruction>
		<instruction />
		<instruction>Dim fs</instruction>
		<instruction>Set fs = CreateObject(&quot;Scripting.FileSystemObject&quot;)</instruction>
		<instruction />
		<instruction>Function Rename_GetNewName ( strFileName, strFullPath, fIsFolder, strOldName, ByRef strNewName )</instruction>
		<instruction />
		<instruction>   Dim strExtension</instruction>
		<instruction>   Dim fileObj</instruction>
		<instruction />
		<instruction>   If (fIsFolder OR 0 = InStr(strFileName,&quot;.&quot;)) Then</instruction>
		<instruction>      Exit Function &apos; Don&apos;t do anything to folders, or files without extensions.</instruction>
		<instruction>   End If</instruction>
		<instruction />
		<instruction>   strExtension = Right(strFileName, Len(strFileName)-(InStrRev(strFileName,&quot;.&quot;)-1))</instruction>
		<instruction />
		<instruction>   If (strExtension = &quot;.avi&quot; OR strExtension = &quot;.mpg&quot; OR strExtension = &quot;.mkv&quot;) Then</instruction>
		<instruction>      strNewName = &quot;V\&quot; &amp; strFileName</instruction>
		<instruction>   Else</instruction>
		<instruction>      Set fileObj = fs.GetFile(strFullPath &amp; &quot;\&quot; &amp; strFileName)</instruction>
		<instruction>      strNewName = Year(fileObj.DateLastModified) &amp; &quot;\&quot; &amp; strFileName</instruction>
		<instruction>   End If</instruction>
		<instruction>                        </instruction>
		<instruction>End Function</instruction>
	</function>
</button>

Perfect! Thanks Leo.

I moved my pictures to another drive. the folders moved but the pictures are lost. I need help and cant seem to find it
keko922@gmail.com

So far you've asked in an unrelated year old YouTube thread, and an unrelated 11 year old forum thread...

Try starting a new thread for your question instead.

And please provide more detail of what you did, and what you see now. (Did you use Opus to move the pictures or something else? Which commands did you use on the files or folders? What is in the folders now?)

Leo, sorry... If you have a few time, can you update your script to move files to "Year/month" (2024/05, 2023/12) folder? TIA

You want one folder per year then one sub-folder per month (that has a picture) ?

EDIT : If that's what you want, the line at the end of the script :

strNewName = Year(fileObj.DateLastModified) & "\" & strFileName

has to be changed to :

strNewName = Year(fileObj.DateLastModified) & "\" & Month(fileObj.DateLastModified) & "\" & strFileName

If what you want is one folder per Year-Month, then replace instead by :

strNewName = Year(fileObj.DateLastModified) & "-" & Month(fileObj.DateLastModified) & "\" & strFileName
2 Likes