将文件从一个子目录移动到另一个子目录II

时间:2016-02-26 06:18:39

标签: bash sh move file-management file-move

我的目录是这样的:

/Users/dave/Desktop/test/untitled_folder_0001/vol_0000
/Users/dave/Desktop/test/untitled_folder_0001/rs

/Users/dave/Desktop/test/untitled_folder_0001/t1
/Users/dave/Desktop/test/untitled_folder_0001/str

我想在shell脚本中的1500~ vol_0000 ****里面将所有rs移到t1struntitled_folder_可能的。

我已经尝试了很多次,但没有在哪里。 我正在写这个,因为我之前无法得到帮助。 这是以前的帖子! 如果这个问题得到解答,我会删除那个以获得冗余。

Moving files from one subdirectory to another

1 个答案:

答案 0 :(得分:2)

最简单的方法可能是循环。

    Use AdventureWorks2014;

IF OBJECT_ID('TempTable1', 'U') IS NOT NULL
    DROP TABLE TempTable1


IF OBJECT_ID('tempdb..#TempRollingSched') IS NOT NULL
    DROP TABLE #TempRollingSched
SELECT  SOD.ProductId,
        RolingSched=MIN(SOH.DueDate)  
        INTO   #TempRollingSched
FROM Sales.SalesOrderHeader SOH
        INNER JOIN Sales.SalesOrderDetail SOD
            ON SOH.SalesOrderID = SOD.SalesOrderID
    WHERE SOH.SalesPersonID <= 274 and 
        SOD.ProductId < 710  
        GROUP BY SOD.ProductId

SELECT #TempRollingSched.ProductId, #TempRollingSched.RolingSched FROM #TempRollingSched


IF OBJECT_ID('tempdb..#TempRollingSchedComplete') IS NOT NULL
    DROP TABLE #TempRollingSchedComplete
SELECT SOH.SalesPersonID, SOD.ProductId as ResourceID,
        SOH.DueDate as DueDate,
        SOD.OrderQty as DayIncrement,
        TRS.RolingSched,
--
--  What I actually want for SchedStart date is 
--  DATEADD(Day, SOD.OrderQty, SOH.DueDate)       FOR THE FIRST RECORD of a Resource ID
--  Then That Date + DayIncrement for subsequent Records
--  
-- The first Three Records for 707 should be 
--      2005-08-14
--      2005-08-18
--      2005-08-28
--
        Row_Number() over (PARTITION BY SOD.ProductID ORDER By SOH.DueDate) as JResourceNumber 
    INTO TempTable1


    FROM Sales.SalesOrderHeader SOH
        INNER JOIN Sales.SalesOrderDetail SOD
            ON SOH.SalesOrderID = SOD.SalesOrderID
            INNER JOIN #TempRollingSched AS TRS ON TRS.ProductID=SOD.ProductID
    WHERE SOH.SalesPersonID <= 274 and 
        SOD.ProductId < 710
    ORDER by ResourceID, DueDate

Select  A.SalesPersonID, 
        A.ResourceID, 
        A.DueDate, 
        A.DayIncrement, 
        SchedStartDate=DATEADD(Day, (SUM(DayIncrement ) OVER  (PARTITION BY  ResourceID ORDER By  JResourceNumber)), RolingSched),  
        A.JResourceNumber   from TempTable1 AS A

...假设我已正确理解目标。