Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 904

Community Tips & Tricks • FileView: Copy and Paste files

$
0
0
User sl23 was asking some time ago if it was possible to copy and paste files using FileView plugin, which the answer is nope. However there's a way to do it using FileView + RunCommand Plugins.

The CMD has a couple of commands that can do it, the one that the test skin I'm sharing uses is xCopy.

FileViewCopyPaste_1.0.rmskin
Desktop2024.12.26-05.43.33.01-ezgif.com-video-to-gif-converter.gif
It includes 2 folders inside @Resources: FolderCopy and FolderPaste. FolderCopy contains 5 images and FolderPaste is empty. The idea is simple, click a file and then click paste to paste it on FolderPaste.

*Images from: https://picsum.photos/

Clicking the file name will set FileName variable to the FileName that comes from the fileview child measure, then clicking on paste will execute the run command measure.

The test skin is pretty basic in function but hopefully it starts a conversation about it and we can give it a better shape here.

xCopy can copy any file or folder and paste it anywhere else, just like pressing ctrl + c and then ctrl + v.

The command is:

Code:

Xcopy "<Source>" "[Destination]" [/flags]
Documentation: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/xcopy

Used on a run command measure it looks like this:

Code:

[CMD]Measure=PluginProgram=%ComSpec% /CPlugin=RunCommandParameter=Xcopy "[&PathSource][#FileName]" "[&PathDestination]" /v /e /h /i Timeout=5000State=HideFinishAction=[!CommandMeasure PathDestination "Update"][!Update]OutputType=UTF8DynamicVariables=1
Where [&PathSource] and [&PathDestination] are FileView parent measures, and [#FileName] is the Name of the file which we want to copy, extracted using FileView child measures.

/v /e /h /i are flags, more information about them is available on the documentation.

There's a flaw on this command though. Although it can copy both files and folders, when it comes to folders, it will copy only what's inside the folder and not the folder itself, for example, let's say you want to copy

SomeFolder\SomeOtherFolder

to

AnotherDestination\

One would expect to get:

AnotherDestination\SomeOtherFolder

But what you'll really get is

AnotherDestination\ContentsOfSomeOtherFolder

Unless you specify the name of the folder to where the files should be copied to, which complicates implementation, however still possible with enough dedication. If you copy a file to a folder that doesn't exist, the folder will be created automatically. You can also create new folders using the command md.


There are other commands available:

Move: Its the same as Ctrl + X and Ctrl + V.

Implementing it is actually easier than xCopy since it only has 2 flags. It would look like this on the same run command measure:

Code:

move "[&PathSource][#FileName]" "[&PathDestination]"
The flags aren't necessary unless you want to be able to overwrite files.

md command can create multiple folders on a single run, either on the same directory, or by creating subdirectories.

The command is:

Code:

md "[&PathDestination][#Directory]"
You can create "[&PathDestination]NewFolder" or even "[&PathDestination]NewFolder\NewSubFolder"

You can also create multiple folders inside a folder, simply separating them with spaces:

md "[&PathDestination]Folder1" "[&PathDestination]Folder2" "[&PathDestination]Folder3"

Deleting stuff is actually more difficult and risky, CMD offers

del: Can only delete files

rmdir: Can only delete folders (and their contents, of course)

Why is it risky? Because these commands won't send anything to the Recycle Bin, stuff deleted with these commands will be totally wiped, and will only be able to be restored (with luck) using software like recuva. So no room for error with these commands, use them at your own risk.

There are no practical risks that I can come up with using xCopy, nor move nor md commands. In the case of move, maybe moving it to a wrong location, however that's not a horrible mistake.

PowerShell also offers commands for these actions, however when I tested them the process was way slower than cmd for my taste.

Statistics: Posted by RicardoTM — Today, 1:18 am — Replies 3 — Views 100



Viewing all articles
Browse latest Browse all 904

Trending Articles