You could turn on flat view (mixed, no folders), then select all and drag to the file display background to move everything to the main folder. That's what I tend to do.
Thanks so much for the quick reply unfortunately it didnt work. I have the following structure:
Parent Folder1999/Sub 1/Sub 2/File1.txt
Parent Folder1998/Sub 1/Sub 2/File2.txt
Parent Folder1997/Sub 1/Sub 2/File3.txt
I need to move the txt files into their respective parent folder and delete the sub folders. I have several of these parent folders that need the txt files moved into them so I figured flattening them would make it easier so I dont have to click into 56 individual folders.
Is that a better description?
The script you sent would move all the flattened files into the current folders, not their respective parent folders.
If you just want to move selected files up one level in Flat View then I think Lxp gave you a command for that in the other thread you asked in:
If you're still stuck please start a new thread as it's confusing having it tacked on the end of other threads that are about slightly different things (or lots of different things).
The first script is only doing half of the listed features for me: With files selected, yes, it moves them into a new folder (still want to figure out how to pre-fill the name box with the first selected file's name), but when I have nothing selected it does nothing at all.
Is this expected given this was made for 11, or might I have done something wrong on my end?
I've updated the root post so the case where nothing is selected works in Opus 12. It'll also use the name of the first file as the default folder name now.
Copying selected objects to a certain pre-defined destination
Would somebody please help me with the following button or hotkey:
I frequently need to move files/folders that I previously manually selected from a network folder to a folder on C:.
I would like it to work exactly as if I used simple cut / paste, i.e. with progress window and with requests in case of identicaly files in destination.
(The context is that I am copying downloaded files from the MAC download folder (which appears as a network drive in the Windows VM) to the Downloads folder in the Windows VM because I want downloads of Mac and Windows to accumulate in one place (i.e., everything in the VM), but don't want to download from Mac INTO the VM directly because the VM is sometimes not running.)
There is also this thread, I wasn't sure where best to post:
Leo, I am answering here still because I think it makes more sense. I hope this is OK -- see below:
I now use a button that does
Copy TO "C:\Users\matthiasernst\Downloads" MOVE
and it works exactly as I want. I hope it's the correct solution.
I am now quoting the above message of user "aussieboykie" because I think there is some problems there which confused me.
First of all, as mentioned by Jon, RENAMEWHENSAME is a bit confusing because it does NOT refer to supression of the rename dialogue (making it automatic). It's idea is to address the situation where you copy a file to the same folder with the intention of creating a copy within the same folder, where a prompt makes no sense. However, MOVING a file within the same folder makes no sense -- indeed, you get an error message. Thus I believe (?) RENAMEWHENSAME only makes sense in combination with COPY that does NOT have a MOVE action specified -- and thus user aussieboykie might not have understood the command?
WHENEXISTS=rename may be what you want instead of RENAMEWHENSAME.
Not sure which message/comment by Jon you're referring to, though. He hasn't posted in this thread or the other one you linked to.
This thread is very difficult to follow with so many unrelated questions under it, which is why a new thread would be better. (You can always put a link to it here if you think it would be useful for other people.)
Very useful functions (for me) that I think Dopus should have built in...
Move Here to New Subfolder:
function OnClick(clickData)
{
var cmd = clickData.func.command;
var tab = clickData.func.sourcetab;
if (clickData.func.sourcetab.selected.count == 0)
{
cmd.RunCommand('CreateFolder READAUTO=no');
}
else
{
var focusI = tab.GetFocusItem.name_stem; //Get the base name of the item in focus
for(var e = new Enumerator(clickData.func.sourcetab.selected); !e.atEnd(); e.moveNext()) { //Each item
if(focusI == e.item().name_stem) {var icase = 1; break;} //If the focused item is in the selected items, set icase to 1 and exit the loop
}
if(icase != 1) {var focusI = tab.selected(0).name_stem;} //If the focused item is not in the selected items, set focusI equal to the base name of the first item in the selected items
cmd.AddLine('@set dir={dlgstrings|Enter new subfolder name|"' + focusI + '"}'); //Use the base name of the item to create the folder
cmd.AddLine('Copy MOVE HERE CREATEFOLDER="{$dir}"'); //Create a folder and move the selected items into it
cmd.Run();
}
}
is there any way to get the first one to work in 2 pane mode? bc when you have something selected in pane 1 and hit the button in pane 2, it just makes an empty folder.
Move Here to New Subfolder ====================================================
User-defined command:movehere-sf Move Here to New Subfolder v1.6.1.osp (17.2 KB)
Button: Move Here to New Subfolder.dcf (278 Bytes) dlg.Control("static3").label = Script.LoadImage("Move.png"); // Icon
Move Here to New Subfolder (Folder name history drop-down list) ========================
User-defined command:movehere-sf-h
After encountering issues with the "Move Everything Up" button, I've made some improvements and wanted to share it with the community. The main problem was that it moved all files and folders simultaneously. This caused a conflict when there were files and subfolders with the same name.
With original button script One/One/note.txt conflicts, at least for me, with One/note.txt
desktop/
└── One/
├── // button executed from here
├── note.txt
└── One/
└── note.txt
I've modified the script to move all files in the current directory up one level before proceeding with the folders. It should help avoid conflicts when there are files and subfolders with the same name.
Here's the improved button script written in JScript:
// Initiate the click event function
function OnClick(clickData) {
var cmd = clickData.func.command;
cmd.deselect = false; // Prevent automatic deselection
// Define the current path and parent path
var currentPath = clickData.func.sourcetab.path;
var parentPath = String(currentPath).split("\\");
parentPath.pop();
parentPath = parentPath.join("\\");
// Initiate a dialog box for user confirmation
var dlg = clickData.func.Dlg; // Initiate a dialog
dlg.message = "Move all the files and folders in the current directory up one level and then delete the current folder?";
dlg.title = "Move Everything Up";
dlg.buttons = "No|Yes";
dlg.icon = "question";
var result = dlg.Show();
// If user confirms, proceed with the operation
if (result == 0) {
try {
// Move files first
var fileEnum = new Enumerator(clickData.func.sourcetab.files);
while (!fileEnum.atEnd()) {
var item = fileEnum.item();
if (!item.is_dir) {
// Make sure the file exists before moving
if (DOpus.FSUtil.Exists(item)) {
cmd.RunCommand('Copy MOVE FILE="' + item + '" TO="' + parentPath + '"');
}
}
fileEnum.moveNext();
}
// Then move directories
var dirEnum = new Enumerator(clickData.func.sourcetab.dirs);
while (!dirEnum.atEnd()) {
var item = dirEnum.item();
// Make sure the directory exists before moving
if (DOpus.FSUtil.Exists(item)) {
cmd.RunCommand('Copy MOVE FILE="' + item + '" TO="' + parentPath + '"');
}
dirEnum.moveNext();
}
// Go to the parent directory
cmd.RunCommand('Go PATH="' + parentPath + '"');
// If the original directory is empty, delete it
if (DOpus.FSUtil.Exists(currentPath)) {
cmd.RunCommand('Delete FILE="' + currentPath + '" NORECYCLE SKIPNOTEMPTY QUIET');
}
} catch(e) {
// Log any error to the output
DOpus.Output("An error occurred: " + e.message);
}
}
}
If anyone has insights on how to resolve this issue using just DOpus scripting, please share your suggestions.
Original button works OK for me in that scenario. At least, there aren't any errors and the files seem to end up in the right place, from a quick check.
(There was an issue with the button missing quotes on the line that removes the old folder, which I've fixed in the root post.)