2) It is possible to select nth file in a folder. I found code on stackoverflow:
Search "Python: Select the first file in a directory"
3) I found similar program which I have to adapt to make my program:
Python Script to iterate through folder and copy all feature classes in MXDs to new file geodatabases?
The code link:
On stackoverflow I found another useful code:
Start processing files from N-th file in folder.
Slice notation can be used in this case:
So it will take time to read code to make for automatio the programa whicg you can use to select and copy or move nth files in folder. I already use similar porgram selecting document types. Code style shall be implemented into blogger.
So I tried to adapt code but with failure of shutil. I think I will have to make copying with os library or other way.
# python OSWALKSHUTIL.py
# cd C:\Users\ANTRAS\Desktop
src = r'C:\\Users\\ANTRAS\\Documents\\LINKING\\1'
dest = r'C:\\Users\\ANTRAS\\Documents\\1'
for path, subdirs, files in os.walk(src):
for name in files:
name = os.listdir(path)
Traceback (most recent call last):
File "OSWALKSHUTIL.py", line 14, in <module>
File "C:\Python27\lib\shutil.py", line 144, in copy2
File "C:\Python27\lib\shutil.py", line 96, in copyfile
with open(src, 'rb') as fsrc:
IOError: [Errno 2] No such file or directory: 'www.google.co.uk_25th_Oct_2017 (1).csv'
I found very useful shutil tutorial with example how to automate. There is no in library possibilities to automate generally with path file index.
There is also simpe solution - with os library enumerate files and the using file name part, 1,2 and etc.. use os.walk method to copy all files to new folder.
Similar solution to rename file in folder
Python script to rename files in directory, transforming spaces to hyphens and the chars to lowercase
|os.rename(filename, filename.replace(, ).lower())|