ajkis / scripts

Ajki's scripts & guides
https://ajkis.github.io/scripts/
324 stars 91 forks source link

PlexUpdateLibrary - Folder Modified Date doesnt change but file does. Questions on pulling just folder from the find command. #24

Open ml3000 opened 7 years ago

ml3000 commented 7 years ago

In my Google Drive the folder Modified date isnt changing but the file is. I can change the depth to 3 and I can grab the changed file that way but how would I pull out just the directory to put that into a log file to get scanned by plex?

Im not very familiar with scripting so I apologize.

--file does not look like it works for plex

hjone72 commented 7 years ago

--file does not work. It has been confirmed by many forum posts.

If you have a look at this script here: https://github.com/ajkis/scripts/blob/master/plex/plexupdatenew.cron it should find folders that have had files updated within them.

ml3000 commented 7 years ago

Thats what I am using.

My modified date on the Season folder does not change within Google Drive. Only the file changes within the folder. I do not know why.

So using a depth of 3 I can grab a file because of the modified date on the file being newer than the last run.

My question is, is there a way of instead of echo'ing the depth of 3 to a log file. Can I echo a depth of 2 with the Season folder instead. Like pull out the actual file name from the string which is being echo'd

hjone72 commented 7 years ago

Here is a small snippet that should do what you're after.

readarray -t FILES < <(find "/mnt/cloud/media/tv_shows" -mindepth 2 -type f)
for value in "${FILES[@]}"; do
        echo "$value" # Full file and path.
        echo `dirname "${value}"` # Folder up to the last '/'
        echo `basename "${value}"` # File name only.
done
ghost commented 7 years ago

I'm still having trouble with it, it seems that rclone doesnt set folder mtime correctly.

ajkis commented 7 years ago

`>Here is a small snippet that should do what you're after.

If you search for files and strip dirname you will need to generate new array and remove duplicates, since otherwise if you have Season 01/Ep1 `Season 01/Ep2 Season 01/Ep3 the same folder will be scanned 3 times instead of only once.

hjone72 commented 7 years ago

I don't agree that the best way to approach this is scanning a cloud directory to find changes. In my solution I am building a list of files based on my local directory, then scanning those folders. Local only hangs around for 1 or 2 days so there isn't that much overlap. By building the folder list from your local directory you aren't putting any load on the cloud services and you still get full access to all mtime ctime ect that some cloud services/mounting software may not support correctly.

ajkis commented 7 years ago

@hjone72 yes I agree and i made scripts for that kind of refresh eg it will only scan exact folders you uploaded: https://github.com/ajkis/scripts/blob/master/plex/plexgeneratefolderlist https://github.com/ajkis/scripts/blob/master/plex/plexrefreshfolderlist

ajkis commented 7 years ago

@ml3000 I completely changed how script works now. https://github.com/ajkis/scripts/blob/master/plex/plexupdatenewfolders.sh

Instead of checking for new/modifies folders the script will check for new/modified files ( since some clouds do not modify folder dates when content in them changes )

Building the array with unique folder names before running Plex Scan, since that one takes long time and uploads during those may be missed.

ml3000 commented 7 years ago

@ajkis Hey, did you delete the script that you linked to above? Thanks

ajkis commented 7 years ago

ajkis Hey, did you delete the script that you linked to above? Thanks

no just renames some scripts