Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

"Rename" files across shares with Python (Solved)

Featured Replies

I'm finally organizing my media properly with TV, Movies, and Music on their own shares. I made a little Python script that handles incoming files, sorting them into their appropriate folder; it worked great when everything was on one share. Not that everything is on different shares, my script has the same symptoms as Windows Explorer - even though files are moving around on the same disk, the file is copied then deleted, taking a bunch of extra time and wasted read/write cycles. Midnight Commander, running on the server, works exactly as expected. Is there any way to emulate this functionality through Python?

 

When everything was on the same share, os.rename() worked flawlessly, but now it throws an error about "different disk drives." I replaced it with shutil.move() but that does the whole copy nonsense. Is this because I'm running the Python script from Windows? If so, is there a way to run it through the server and would that fix the problem? The only Python environment I found was a PyCharm docker and that really wasn't a good solution, since the docker is sandboxed. Any help would be greatly appreciated. Thanks!

Edited by Crlaozwyn
Add Solved tag to title

Every OS in the world suffers the same "flaw".  Renames across mount points (shares) always does a copy / delete instead of a rename operation.  It's the proper way to do things, and is 100% correct, regardless if the files / shares are actually on the same drive or not.

  • Author
2 hours ago, Squid said:

Every OS in the world suffers the same "flaw".  Renames across mount points (shares) always does a copy / delete instead of a rename operation.  It's the proper way to do things, and is 100% correct, regardless if the files / shares are actually on the same drive or not.

Thanks Squid. I appreciate the response. MC does not appear to copy/delete, as "moving" a 10GB file happens instantly. The issue, if it really was an issue at all, was that I was running the Python script from Windows, which didn't recognize the shares as being on the same drive. Once I ran the script on the server, it was instant again.

 

However, I've realized in testing that this behavior ignores split level settings for the share. I suppose my use-case is more complicated than I thought, because what I actually want is for it to move the pointer when the end point (EG season/artist) is on the same drive, but follow the split level settings to put it on the proper drive if different. Looks like I'll be writing some manual tests to determine start/endpoint drives and choose a command based on which outcome is needed.

2 hours ago, Crlaozwyn said:

MC does not appear to copy/delete, as "moving" a 10GB file happens instantly

Because the command line bypasses the entire system of mount points, since you're navigating on both to be /mnt/user/abc and /mnt/user/def so the mount point in both cases is /mnt/user

 

2 hours ago, Crlaozwyn said:

However, I've realized in testing that this behavior ignores split level settings for the share.

Along with included / excluded, useCache settings.  Because of the single mountpoint

  • Author
2 hours ago, Squid said:

Because the command line bypasses the entire system of mount points, since you're navigating on both to be /mnt/user/abc and /mnt/user/def so the mount point in both cases is /mnt/user

 

Along with included / excluded, useCache settings.  Because of the single mountpoint

Thanks for the clarity - helps explain what I'm seeing. I'll do some more testing to see if the move command works as desired or if I need to emulate the functionality.

  • Crlaozwyn changed the title to "Rename" files across shares with Python (Solved)

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.