Automatically shorten paths over a character count limit in bash

خرید بک لینک

Windows and tools running on windows servers (eg. OneDrive) have a limit on path lengths.

I am looking for a command line tool in OSX/Linux/Unix to, within a directory, shorten all paths above a path length threshold, for example, by keeping the first 5 characters and the last 5 characters of each folder/file name in overly long paths, starting with the names of folders and files most distant from the root (ie. most nested).

ie

folder_very_very_long_name/folder_very_very_long_name/folder_very_very_long_name/file_very_very_long_name

could become

folder_very_very_long_name/folder_very_very_long_name/folde_name/file__name

I can already identify the troublesome paths using:

find . -name * -type f | perl -ne 's/(.*)/print length($1), " $1n"/e' | sort -nu

from:

https://discussions.apple.com/thread/2590442?tstart=0

Recent Questions...

ما را در سایت Recent Questions دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 299 تاريخ: شنبه 2 مرداد 1395 ساعت: 19:39

صفحه بندی