Hi,
I need to organize thousands of directories full of files.
I want to move these directories into other subdirectories.
For example, all the directories that start with 01, move to
a directory named "one", all directories that start with 02, move
to a directory name "two", and so on....
I can't seem to find any easy way to do this.
Looks like shutil.move only lets you move if the subdirectory DOES
NOT exist, so after the first directory moves, the script blows up on
the second move.
I guess you could use shutil.copy or shutil.copytree but then you have
to
delete as well. Much longer process when you have hundreds of
gigabytes of data.
Thanks for your help!
R.D. 3 1869
DataSmash wrote:
Hi,
I need to organize thousands of directories full of files.
I want to move these directories into other subdirectories.
For example, all the directories that start with 01, move to
a directory named "one", all directories that start with 02, move
to a directory name "two", and so on....
I can't seem to find any easy way to do this.
Looks like shutil.move only lets you move if the subdirectory DOES
NOT exist, so after the first directory moves, the script blows up on
the second move.
I guess you could use shutil.copy or shutil.copytree but then you have
to
delete as well. Much longer process when you have hundreds of
gigabytes of data.
Thanks for your help!
R.D.
Use win32.moveFile method instead. This links directly to the Windows
MoveFile method that just moves the directory entries around.
From Win32 Documentation:
win32api.MoveFi le
MoveFile(srcNam e, destName)
Renames a file, or a directory (including its children).
Parameters
srcName : string
The name of the source file.
destName : string
The name of the destination file.
Comments
This method can not move files across volumes.
-Larry
Thanks Larry, I'll give that a try...
R.D.
>
Use win32.moveFile method instead. This links directly to the Windows
MoveFile method that just moves the directory entries around.
From Win32 Documentation:
win32api.MoveFi le
MoveFile(srcNam e, destName)
Renames a file, or a directory (including its children).
Parameters
srcName : string
The name of the source file.
destName : string
The name of the destination file.
Comments
This method can not move files across volumes.
-Larry
On Apr 16, 9:36 pm, Larry Bates <larry.ba...@we bsafe.comwrote:
DataSmash wrote:
Hi,
I need to organize thousands of directories full of files.
I want to move these directories into other subdirectories.
For example, all the directories that start with 01, move to
a directory named "one", all directories that start with 02, move
to a directory name "two", and so on....
I can't seem to find any easy way to do this.
Looks like shutil.move only lets you move if the subdirectory DOES
NOT exist, so after the first directory moves, the script blows up on
the second move.
I guess you could use shutil.copy or shutil.copytree but then you have
to
delete as well. Much longer process when you have hundreds of
gigabytes of data.
Thanks for your help!
R.D.
Use win32.moveFile method instead. This links directly to the Windows
MoveFile method that just moves the directory entries around.
From Win32 Documentation:
win32api.MoveFi le
MoveFile(srcNam e, destName)
Renames a file, or a directory (including its children).
Parameters
srcName : string
The name of the source file.
destName : string
The name of the destination file.
Comments
This method can not move files across volumes.
-Larry
Instead win32api, use "native" shutil module
import shutil
shutil.move(src ,dest)
Recursively move a file or directory to another location. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Johann Blake |
last post by:
I can hardly believe I'm the first one to report this, but having gone
through the newsgroup, it appears that way.
I would like to open a solution in the VS.NET IDE that consists of
multiple DLLs and a test application (an .EXE). The .EXE is my startup
application. All the DLLs are shared components. This means that they
contain a key and are stored in the GAC.
When I go to run the test application in the IDE, it will not execute...
|
by: David |
last post by:
I have been working on trying to write a directory watcher service.
One of the requirments is that it be able to watch multiple
directories, not sub directories of one parent directory, but just
multiple directories.
I have hit a snag and don't know how to get around it.
Basically I read in a list of directories from the app.config and stuff
them into an array, so that I have something like this:
sDirsToWatch = "C:\Temp"
|
by: BPearson |
last post by:
Hello
I would like to have several sites share a single web.config file. To accomplish this, I would point the root of these sites to the same folder. Is there any reason why I might not want to do this? (IIS 5 or 6
In case you're wondering why I would do this, we have many web sites on a single server, and there are groups of sites that need to share common configuration information. I'd like to ease some administration by having one...
|
by: Sammy |
last post by:
On a Windows 2003 Server machine that has multiple IIS web
sites, how does one control which web site the new web
application gets created under?
Thank you,
Sammy
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |