Skip to main content

Posts

Showing posts from September, 2018

Some find commands - useful for copying iCloud Photos to another service.

I've found these commands really helpful when navigating an iCloud Photo library on a Mac. The native Photos Application on MacOS prohibits a lot of bulk file activity.  These commands should be run from Terminal. Before starting, it's best to place yourself in the following directory "/Users/**your username**/Pictures/Photos Library.photoslibrary" This command is best executed from the "Masters" directory  find . -iname  *.cr2  -exec ls -lh {} \; It finds all CR2 files and reports the file sizes   You could change the ls to a copy, say to copy the image to another folder, like another cloud drive.  Find all file types outside a defined list, and filter those only in the Masters directory find . -iname *.* | grep Masters | grep -v -i -E '\.jpg|\.jpeg|\.heic|\.png|\.cr2|\.gif|\.mp4'  Find all file types IN a defined list, and filter those only in the Masters directory find . -iname *.* | grep Masters |

Get Results of Stored Procedure and insert to temp table

I needed to get the storage results recently of a bunch of SQL tables.   Here's how I did it. 1) Create a temporary Table CREATE TABLE #spaceused ( nameout VARCHAR(50) ,rowsout int ,reservedout VARCHAR(50) ,dataout VARCHAR(50) ,index_sizeout VARCHAR(50) ,unusedout VARCHAR(50) ) 2) Send the results to the table, using sp_spaceused  I also created a script to generate about 100 of these INSERTs INSERT INTO #spaceused EXEC sp_spaceused N'TableName' ; GO 3) Query the results... SELECT TOP 10 * FROM #spaceused 4) Delete the temp table when done.  DROP TABLE #spaceused

Send a powershell object straight to SQL Server

Recently I needed to copy directory contents details to an SQL Server. This is the powershell script I used to do it. $path = "C:\Files\" $Table  = Get-ChildItem -Path $path |  Select-Object Name , FullName , CreationTime , Length Write-SqlTableData -ServerInstance "PBRUCE-DT" -DatabaseName "PlayDatabase" -SchemaName "dbo" -TableName "FileInfoArchive" -InputData $Table  -Force