title: Can I shrink a SQL database log file via file path / by using it's self?
body: <p>I am designing a program which shrinks database log files across a network.</p>
  
  <p>The log file will not always be in the same format so I want to shrink it via the path name. To get the path names at the moment I am writing:</p>
  
  <pre><code>select top 2 physical_name as current_file_location FROM sys.master_files where physical_name like '%adventureworks%'
  </code></pre>
  
  <p>My script to shrink the log files are:</p>
  
  <pre><code>ALTER DATABASE adventureworks2012 SET RECOVERY SIMPLE DBCC 
  SHRINKFILE ('c:\Program Files (x86)\Microsoft SQL Server\MSSQL10.50\MSSQL\DATA\adventureworks2012_log.ldf', 1) 
  ALTER DATABASE adventureworks2012 SET RECOVERY FULL
  </code></pre>
  
  <p>This returns the error:</p>
  
  <blockquote>
    <p>Could not locate file 'c:\Program Files (x86)\Microsoft SQL
    Server\MSSQL10.50\MSSQL\DATA\AdventureWorksLog.ldf' for database
    'AdventureWorks' in sys.database_files. The file either does not
    exist, or was dropped.</p>
  </blockquote>
  
  <p>Is there a way I can make it select its self regardless of log file naming convention?</p>