January 18, 20251 yr This is kind of a niche problem I'm having. I run all my media through kodi (i just don't like how plex looks). Been running kodi for years now with a mysql database set up so each tv in the house is connected to the same db. I have my kodi sources sorted as date modified, so newest movies and show episodes are at the top of the list ready to be scraped. Now my huuuuuge problem. I just transferred 20tb over to my new unraid server. Issue? It has changed the date modified on all of my media to the date it was transferred over, so now movies and shows that I downloaded years ago are now at the top. Doing some google searching I found out if I had used a windows cmd "robocopy" it would have kept the original date modified for every folder. I just spent a week transferring all of my data. I do NOT want to have to delete everything and start over. Talking with chatgpt, it made me a few different scripts in both autoit and python that would change directory date modified to one of the video files inside the directory. It worked great!....for some of the folders. About 20% of the folders went back to the original dates. If I have any folders like /TV/Showname/Season1/episode.mkv the Season1 folder will get its date updated, but the main directory won't. But the majority of my shows are just set up like /TV/Showname/episode.mkv and the date did not change. I went through permissions, ownerships, making sure the folders are not read-only, manually inputting the touch and sync commands. Nothing seems to work. It then said two possible reasons were that noatime or +i (immutable) were set on my shares. It gave me two commands to test for these, noatime is definitely set but i cannot use the "chattr" command, it throws an error so I cannot check for immutable. If noatime or +i were the issue, how come some of the directories did change their date modified? What am I missing to this puzzle to reset the rest of my folders? I've been at this for 6 hours now trying to figure it out and it's killing me.
January 18, 20251 yr Community Expert it may not have permission to write and update the metadata... you can use a script to fix this... #!/bin/bash # Directory to process (provide as argument or hardcode) TARGET_DIR=${1:-"/path/to/your/media"} # Custom date to set (YYYY-MM-DD HH:MM:SS) if original times are unavailable DEFAULT_DATE="2020-01-01 00:00:00" # Ensure the target directory exists if [[ ! -d "$TARGET_DIR" ]]; then echo "Error: Target directory '$TARGET_DIR' does not exist." exit 1 fi echo "Processing directory: $TARGET_DIR" # Function to update permissions and ownership fix_permissions_and_ownership() { echo "Updating permissions to 777..." chmod -R 777 "$TARGET_DIR" echo "Setting ownership to nobody:users..." chown -R nobody:users "$TARGET_DIR" } # Function to fix file modification dates restore_file_dates() { echo "Restoring file modification dates..." find "$TARGET_DIR" -type f | while read -r file; do # Try restoring the original modification date from xattr (if available) original_date=$(getfattr -n user.modified_time --only-values "$file" 2>/dev/null) if [[ -n "$original_date" ]]; then # Convert to touch-compatible format if needed formatted_date=$(date -d "$original_date" '+%Y%m%d%H%M.%S') touch -t "$formatted_date" "$file" echo "Restored date for: $file" else # Fallback: Apply default date if no metadata available touch -d "$DEFAULT_DATE" "$file" echo "Set default date for: $file" fi done } # Start processing fix_permissions_and_ownership restore_file_dates echo "Processing complete!" kodi may alos require a umaks, puid and pgid to also help this in the future...
January 18, 20251 yr Community Expert Likely Causes noatime Mount Option: This prevents the system from updating access times, which might interfere with modification date updates. Immutable Attribute (+i): Files or directories marked as immutable cannot be changed or modified. If you can't use chattr, this might still be in play. Permissions or Ownership Issues: Some directories might have permissions or ownership settings preventing updates. File System Peculiarities: Certain file systems or Unraid configurations might behave differently for metadata updates. updated script: #!/bin/bash # Path to the share or folder TARGET_DIR=${1:-"/mnt/user/share_name"} # Ensure the target directory exists if [[ ! -d "$TARGET_DIR" ]]; then echo "Error: Target directory '$TARGET_DIR' does not exist." exit 1 fi echo "Processing directory: $TARGET_DIR" # Function to reset attributes reset_attributes() { echo "Resetting immutable attributes (if set)..." find "$TARGET_DIR" -exec chattr -i {} + 2>/dev/null } # Function to update permissions and ownership fix_permissions_and_ownership() { echo "Updating permissions to 777..." chmod -R 777 "$TARGET_DIR" echo "Setting ownership to nobody:users..." chown -R nobody:users "$TARGET_DIR" } # Function to reset modification dates reset_modification_dates() { echo "Resetting modification dates..." find "$TARGET_DIR" -type d -exec touch -d "$(date '+%Y-%m-%d %H:%M:%S')" {} + } # Execute steps reset_attributes fix_permissions_and_ownership reset_modification_dates echo "Processing complete!"
January 18, 20251 yr Author Thank you but unfortunately that did not work.. I run touch -m -t "201712032212.48" "/mnt/user/media/Video/TV/the last man on earth" touch -m -t "201712032212.48" "/mnt/user/media/Video/TV/the\ last\ man\ on\ earth" sync but the directory still has the date it was copied drwxrwxrwx 1 nobody users 6 Jan 17 13:29 the\ last\ man\ on\ earth/
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.