Link | LI_UnreferencedFiles |
Author | Eric Landmann |
Category | File |
Version | 8.5.x |
License | Public Domain |
Posted | 23 Jul 2007 |
Updated | 23 Jul 2007 |
More by this author... |
--Returns a list of files examined in sequence, and at the end, an alpha-sorted list of files not referenced in any other file in that directory.
--No other file manipulation is done, it outputs just a formatted listing.
--Checks to see if any particular file in a directory is referenced in a .lasso or .inc file, but not vice-versa.
--Ignores .DS_Store.
--When a reference to a file is found, a message is output "Reference found!" which is handy for a quick visual check.
LI_UnreferencedFiles: -Path='/foldertoexamine/';
Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.
• = This file or directory is ignored
\n'; // Loop through directory and examine each file Loop:(#FolderArray->Size); Local:'CurrentFile' = (#FolderArray)->(Get:(Loop_Count)); #FormattedOutput += 'Checking if referenced: ' (#Path)(#CurrentFile); If: !(#CurrentFile)->EndsWith('/') && !(#CurrentFile)->BeginsWith('.DS_'); #FormattedOutput += '
\n'; // Examine each file to see if filename is referenced in that file Loop:(#FolderArray->Size); // Check to see if it is not a directory If: (File_IsDirectory:(#FolderArray->(Get:(Loop_Count)))) == false; Local:'ThisFile' = (#FolderArray->(Get:(Loop_Count))); // Check to see if .lasso or .inc file If: !(#ThisFile)->BeginsWith:'.DS_' && ((#ThisFile)->EndsWith:'.lasso' || (#ThisFile)->EndsWith:'.inc'); #FormattedOutput += ' Looking inside: ' (#ThisFile) '
\n'; Local:'ThisFileRead' = (File_Read: (#Path)(#FolderArray->(Get:(Loop_Count)))); // If the filename is referenced in the file being examined, add it to the array If: (#ThisFileRead >> #CurrentFile) && (#UsedFiles->(Find: #CurrentFile)->size == 0); #UsedFiles->(Insert: #CurrentFile); #FormattedOutput += ' Reference found!
\n'; /if; /if; /If; /Loop; else; #FormattedOutput += ' •
\n'; /if; /Loop; // Put Unused files in array Loop: (#FolderArray->Size); If: (File_IsDirectory:(#FolderArray->(Get:(Loop_Count)))) == false; Local:'CurrentFile' = (#FolderArray->(Get:(Loop_Count))); If: !(#CurrentFile)->BeginsWith('.DS_'); If: #UsedFiles->(Find: #CurrentFile)->size == 0; #UnusedFiles->Insert: #CurrentFile; /if; /If; /if; /Loop; // Sort the array for readability #UnusedFiles->sort; // Output HTML header #FormattedOutput += 'Unreferenced Files List
\n'; #FormattedOutput += '\n'; Iterate: (#UnusedFiles), (#UnusedFiles->size); #FormattedOutput += (Loop_Count) ': '; #FormattedOutput += (#path)(#UnusedFiles->(Get:Loop_Count)); #FormattedOutput += '
\n'; Return: Encode_Smart:(#FormattedOutput); /Inline; /Define_Tag; ?> [LI_UnreferencedFiles: -Path='/private_admin/']
\n'; /Iterate; #FormattedOutput += '
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft