Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Some help with moving files
#2
generally, executable files are kept in a bin directory
pictures would go in a directory named images.
This is a pseudo standard, which can be deviated from, but it is suggested naming.

look at pathlib: https://docs.python.org/3/library/pathlib.html
it maked file and directory navigation a snap.
for example, to create a refrence to your home directory, the code would be:
from pathlib import Path

home = Path('.')
Next to create your bin directory under home you would use:
bin = home / 'bin'
bin.mkdir(exist_ok=True)
this will create the directory if not there, and only if not there.

Now if you wanted to get a list of all files in bin:
print([filename for filename in bin.iterdir() if filename.is_file()])
Reply


Messages In This Thread
Some help with moving files - by ACSpeck - Apr-10-2018, 11:01 PM
RE: Some help with moving files - by Larz60+ - Apr-11-2018, 01:01 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Moving specific files then unzipping/decompressing christophereccles 2 2,378 Apr-24-2021, 04:25 AM
Last Post: ndc85430
  Moving files to Folders giddyhead 13 9,193 Mar-07-2021, 02:50 AM
Last Post: giddyhead
  Moving Files From Subdirectories To Another Directory Harshil 5 4,024 Oct-06-2020, 10:52 AM
Last Post: ndc85430
  Moving Files Evil_Patrick 4 2,503 Oct-02-2019, 02:56 AM
Last Post: Evil_Patrick

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020