-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically convert to new filepath
If you're using the legacy filepath but want to use the new filepath, the script will automatically handle it for you. Posts > Images > img.jpg >> Posts > Paid > Images > img.jpg Image folder will automatically be removed IF there's nothing left in there.
- Loading branch information
1 parent
99747a7
commit 989cca2
Showing
5 changed files
with
25 additions
and
5 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import os | ||
import json | ||
from itertools import chain | ||
import shutil | ||
|
||
|
||
def sorter(user_directory, api_type, location, metadata): | ||
legacy_directory = os.path.join(user_directory, api_type, location) | ||
if not os.path.isdir(legacy_directory): | ||
return | ||
legacy_files = os.listdir(legacy_directory) | ||
metadata_directory = os.path.join( | ||
user_directory, "Metadata", api_type+".json") | ||
results = list(chain(*metadata["valid"])) | ||
for result in results: | ||
legacy_filepath = os.path.join(legacy_directory, result["filename"]) | ||
filepath = os.path.join(result["directory"], result["filename"]) | ||
if result["filename"] in legacy_files: | ||
shutil.move(legacy_filepath, filepath) | ||
if not os.listdir(legacy_directory): | ||
os.removedirs(legacy_directory) |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,4 +3,4 @@ beautifulsoup4 | |
urllib3 | ||
win32-setctime | ||
lxml | ||
pysocks | ||
pysocks |