I've been trying to copy files from one directory to another and then changing all the files I moved into .txt files. The only problem is that there are multiple, probably 30+ different extensions and hard coding them is not an option because there could be different extensions in different output folders. I've been able to move all the files from one to another pretty easily, but being able to change every extension in a folder (.ser, .pbr, etc,) to a .txt has proven difficult. If anyone could help that would be great. This is my code for moving files from one folder to another so I just need to be able to change the files to .txt either while they are being moved or after they've been copied to the new folder.
src = 'L:/Development/DCS/UL/Dev\202209\1_202206_4355_4359/OUTPUT/202112'
trg = 'L:/Development/DCS/UL/Dev/Test Output'
files=os.listdir('L:/Development/DCS/UL/Dev/202209/1_202206_4355_4359/OUTPUT/202112')
# iterating over all the files in
# the source directory
for fname in files:
try:
# copying the files to the
# destination directory
shutil.copy2(os.path.join('L:/Development/DCS/UL/Dev/202209/1_202206_4355_4359/OUTPUT/202112',fname), 'L:/Development/DCS/UL/Dev/Test Output')
except:
print ("error")
pass
Related
Is there a loop I can use to create .xlsx files from .bracken files I currently have and channel them into an output folder?
All that I have now is to convert my .bracken files into .xlsx files using this code cat MG-ABCD12345-0.genus.bracken > MG-ABCD12345-0_genus_bracken.xlsx and files are going into my current working directory. I would like the output in a folder called bracken_excel_files which is located within my current working directory. I would prefer to use common commands such as for for the loop for easier understanding.
bracken appears to be generating/sharing the same output format as kraken, which I saw somewhere to be tab-delimited fields.
If that is true, then that is the essence of what CSV files are.
In that case, you don't need to use the "cat" command (CPU and I/O consuming). You simply need to rename the file with a ".csv" suffix (to make the file format explicitly visible for others), then import that into Excel or OpenOffice/LibreOffice Calc. Each of those tools offer different options for interpreting the input when you use the "Import" function to open the files.
Is there an efficient alternative method preferably using WinRar on Windows 10 to extract selected files and folders from a single zip archive into multiple destination folders simultaneously, instead of one operation at a time?
I was sure the 'extract one to many' concept would exist in the software, but nothing is mentioned in the Help facility on how to select multiple destination folders.
Thank you.
I normally open the archive (using WinRar in Windows 10 Home), select all the file and folder content from within the parent folder but not the parent itself (using SELECT A ) and then use 'EXTRACT TO' to navigate and select the destination folder.
Once the archive has been unzipped and overwritten any existing files and folders, I then repeat the process manually, about 10-15 times to extract everything still previously selected into several more unique destination folders until completed.
I would like to be able to select the multiple destination folders in one go, making multiple copies simultaneously.
What is a good way to copy all files in a folder to another one? I don't want to copy the whole folder, just all it's content.
More precise, I want to move all files and folders in a folder one folder up. Example: I want all files and folders in \myfolder\data\ moved to \myfolder\.
What would be an easy way to do that?
I'm currently trying to compile a large project, which has a lot of folders with a lot of subdirs and subfiles.
These files all need to be in the right folder with the right name.
In the main folder where also the .py file is, are 2 folders with all the files.
The problem is:
I need to add all these in the .exe file. These are Like 170MB, So adding them all per hand is not an option.
It is also important that everything is in one .exe file. Does anyone know how to do this?
Does anybody know of any way (on Windows) to create an archive (zip, rar,..) and adding files to it by importing a list of files to be added (say from a CSV or text file or simply pasted) that need to be archived. Say I have a simple list of 1,000 files across multiple directories that I want to add to an archive, this would be a much simpler method of doing it than adding each file individually. Also I do not want to arhive the entire directory as it is absolutely massive.
eg:
c:\somedir\file1.php
c:\somedir\somesubdir\file2.php
c:\someotherdir\file3.php
...
And no I do not want to import all files in certain directories, the hundreds of files are scattered across tens of directories which also contain lots of other files that I do not want to archive.
Thanks
rar.exe from WinRAR has the following option:
n#<list> Include files listed in specified list file