From Clipboard or File v4.1

These rename presets take lines from clipboard or a text file and use them as new filenames or as part of new filenames.

Script information
From clipboard or file rename script version 4.1 (works in Directory Opus 12 and above, tested with Directory Opus 13.1)
by Henrik Ripa (henrik@gieron.info) 2024-02-05

Changelog for version 4.1

  • Removed the dropdown in the dialog for selecting where to get filenames from, use the From Clipboard or From File presets instead
  • Removed the dropdown in the dialog for selecting what to do with empty lines, the option to skip empty filenames is now a checkbox
  • Removed the option to use empty filenames since I can't see anyone wanting this (the option is still present in the script itself)
  • New option to trim and collapse spaces in filenames (on by default)
  • Now determines if line is empty after replacing illegal characters and trimming spaces
  • The file to get filenames from can now have an absolute path
  • Files less than three bytes long now works properly

Installation
Download and unzip the .orp files.

Open the Directory Opus rename dialog. Select Import Preset File from the Preset Management menu and open 'From Clipboard.orp'. Close the Directory Opus rename dialog.

Open the Directory Opus rename dialog. Select Import Preset File from the Preset Management menu and open 'From File.orp'. Close the Directory Opus rename dialog.

Instructions
This script replaces the string 'MARKER' in new file names with lines taken from the clipboard or from a text file. If the lines include any characters that are illegal in filenames they will be removed.

If a text file is used it must either be located in the same directory as the files that you want to rename.

When the text file is in place, or you have copied some text to the clipboard, select the files you want to rename. The order of the selected files in the lister must be the same as the order in the text file. Then click the rename button and select this script under presets.

Set up the old name and new name fields so that the the string 'MARKER' is present in the new file names. You can use standard rename, regular expressions or find and replace. Inspect the results in the preview pane and click OK.

If you have problems you can start by examining the script output below the editor. If you find a bug or have a feature request you can either go to the Dopus Resource Centre forum thread where you got this script from or send me an email.

From Clipboard or File 4.1.zip (9.9 KB)

1 Like

Any reason not to update the old thread rather than make a new one? Does the new version require Opus 13 or similar?

I wasn't sure what was preferred, but since I couldn't update the title of the old thread I thought creating a new one was better.

It works in Opus 12 and above, I probably should make that clear in the post.

Great script. Wouldn't it be better to create a title "From Clipboard or File" and put any version in it? I think it's easier for users to find the latest version.

To get filenames if copying files to clipboard.

' Reads text from clipboard
Function focGetTextFromClipboard( )
'  dim hto, text
'  set hto = CreateObject("htmlfile")
'  text = hto.parentwindow.clipboardData.GetData("text")
  dim text, objClipFiles, x
  If DOpus.GetClipFormat() = "files" Then
    Set objClipFiles = DOpus.GetClip("files")
	For each x in objClipFiles
		'eioPrint x.display_name & " 1"
		If x.display_name <> "" and x.display_name <> x.name Then
			text = text & vbLf & x.display_name
		Else
			'eioPrint x.name & " 2"
			text = text & vbLf & x.name_stem_m
		end IF
	Next
	text = Replace(text, vbLf, "", 1, 1)
	'eioPrint text
  Else
    text = DOpus.GetClip("text")
	'eioPrint text
  end If			
  'if (VarType(text) <> vbString) then text = ""
  focGetTextFromClipboard = text
End Function

Add chinese language / 添加了中文翻译,便于中文用户使用

From Clipboard or File-chs.zip (11.6 KB)