Apologies for the delay in responding but I had a number of time sensitive items to deal with at work.
Appreciate the assistance and input…it is interesting that something that – at least to me – would be a basic need [i.e. spanning / searching a folder and all its subfolders] is so complicated.
A few follow up to the previous post:
- Although I post that I did not want to use a shells script and wanted to use AppleScript I did squeeze in some reading time and am reversing course as it seems the “find” command was made for this thing as it recursively depends the directory tree [which AppleScript has no way of easily doing].
I do however need to understand the code I am using so – at least for now – will not be using the awk command as I have yet to read up on it.
I have decided to therefore use – at least for now – as less efficient two step approach in the I will i) assign all the filenames in the selected folders and all subfolders to a variable as a list and ii) loop through the resulting list to identify those filenames [inclusive of the full path] that are over a user defined number of characters.
I tried using the below code but am getting an error message which reads “Finder got an error: sh: /usr/bin/find/Users/JoelC/Documents/American Express/type: Not a directory”…how do I fix the syntax to get this to work…this is terribly frustrating as I can get the find commend to work in terminal but for some reason not within a shell script…would greatly appreciate the fix!
-- Pick the folder (and sub-folders) whose filename lengths will be compared / tested against maxCount
set folderTarget to (choose folder with prompt "Choose the disk / directory / folder whose file lengths' will be compared against maxCount" default location (path to home folder))
set folderTarget to POSIX path of folderTarget
--set filesAll to get files of folderTarget
set filesAll to paragraphs of (do shell script "/usr/bin/find" & quoted form of folderTarget & "type -f")
[color=red]<<EDIT @ 7:15 EDT: I think that this has been fixed…I have changed the code to:
set filesAll to paragraphs of (do shell script “/usr/bin/find " & quoted form of folderTarget & " -type f”)>>[/color]
- I have a number of files with long files names – some in excess of 255 characters – with the consequence that when I copy / move files from the originating drive to secondary drives not all the files are being properly copied.
I therefore want to identify all files over 255 characters to avoid this happening but – and here is the question – does the 255 character limit apply to HFS file format/nomenclature OR the POSIX file format/nomenclature?
While on the point – if the answer is that I should be using the POSIX file format/nomenclature then at the risk of asking a naive question what character does the count start with…for example, if a file were names /User/Joelc/Documents/test_file.docx then what is the first character in the 255 character limit [i.e. is it the “/” in “/User”, is it the “U” in “User”, etc.?]?
-
@StefanK at your post #9
Appreciate this and will give it a go once i) I get understand the fix to 1. above and ii) I have time to read up on the awk command.
- @ Marc Anthony at your post #12
Appreciate your suggestion which I tried but cannot report back on as my MBA timeout…it seems – as I had this experience with my own attempting coding – that the entire contents command/dump is very slow to execute.
I will come back to this if I cannot get a solution to 1. above which I hope will work once I get my syntax sorted.
Thank you for your referral to Terminal / man find which was helpful…this learning curve --though enjoyable – is steeper than I anticipated!
- @ Nigel Garvey at your post #13
Appreciate you jumping in and taking the time to help again – truly!
Appreciate – as in post # 12 – your suggestion which I tried bit cannot report back on as my MBA timeout…it seems – as I had this experience with my own attempting coding – that the entire contents command/dump is very slow to execute.
I will come back to this if I cannot get a solution to 1. above which I hope will work once I get my syntax sorted.
- @ McUsrll at your post # 14
Appreciate your response and will try this out later tonight and report back…thank you!