找到具有相同基本名称和副本的Windows文件

时间:2017-07-27 15:33:26

标签: powershell-v3.0

对PowerShell有点新意 - 我有一个文件夹,里面有一个索引文件(* .txt,如1234.txt)和相关的pdf文件(1234.pdf或1234_2.pdf)什么是powershell命令,用于查找类似的基本名称和将它们移动到另一个文件夹(文件名的数字部分每次都会为每组文件更改) 谢谢你的帮助

2 个答案:

答案 0 :(得分:0)

您只需使用Move-Item /path/to/files/basename.* /target/path/

即可

对于某些高级解决方案,您可以将Get-ChildItemWhere-ObjectBasename

一起使用

答案 1 :(得分:0)

枚举.txt文件,然后为每个.txt文件移动所有文件 <form id="mainForm" action="partnerProfileInsert.jsp" method="GET"> <div class="wrap"> <div id="compulsoryDetails" class="fleft"> <div class="mainDivs"> <div>Select F_Partner</div> <div style="align:center"> <select id="fPartner" name="fPartner"> <option value="evolution">evolution</option> <option value="evolutionreport">evolutionreport</option> </select> </div> </div> <br> <div class="mainDivs"> <div> Please input the BrandName to be added: </div> <div> <input type="text" id="brandName" name="brandName" class="brandName"> </div> </div> <br> <div class="mainDivs"> <div> Please input the F_Account_ID : </div> <div> <input type="text" id="fAccountId" name="fAccountId"> </div> </div> <br> <div class="mainDivs"> <div> Please input the F_URL : </div> <div> <input type="text" id="fUrl" name="fUrl"> </div> </div> <br> <div style="margin-left:200px"> <button type="button" id="firstStepProceed" onclick="firstProceed()">Next>></button> </div> </div> <div id="hiddenDetails" class="fright" style="display:none"> <div style="color:red"> Please Review thw PreFilled Details and Click <a href="javascript:enableDiv('hiddenDetails')">here</a> if you want to Change any Value: </div> <br> <br> <div> <div style="float:left"> F_PARTNER_PROFILE_ID: </div> <div style="float:right;margin-right:380px"> <input type="text" id="fPartnerProfileId" name="fPartnerProfileId"> </div> </div> <br> <br> <div> <div style="float:left"> F_MODE: </div> <div style="float:right;margin-right:380px"> <input type="text" id="fMode" name="fMode"> </div> </div> <br> <br> <div> <div style="float:left"> F_IS_ACTIVE: </div> <div style="float:right;margin-right:380px"> <input type="text" id="fIsActive" name="fIsActive"> </div> </div> <br> <br> <div> <div style="float:left">F_PASSWORD:</div> <div style="float:left;margin-left:300px"> <input type="password" id="fPassword" name="fPassword"> <input type="text" id="fPasswordText" style="display:none" name="fPasswordText"> </div> <div style="float:right;margin-right:210px"> <input type="checkbox" id="showHide" onchange="passwordShow()" /> <label for="showHide" id="showHideLabel">Show Password</label> </div> </div> <br> <br> <div> <div style="float:left"> F_SECRET_KEY: </div> <div style="float:right;margin-right:380px"> <input type="text" id="fSecretKey" name="fSecretKey"> </div> </div> <br> <br> <div> <div style="float:left"> F_CHECK_MD5: </div> <div style="float:right;margin-right:380px"> <input type="text" id="fCheckMD5" name="fCheckMD5"> </div> </div> <br> <br> <div> <div style="float:left"> F_CUSTOM1_NAME: </div> <div style="float:right;margin-right:380px"> <input type="text" id="fCustom1Name" name="fCustom1Name"> </div> </div> <br> <br> <div> <div style="float:left"> F_CUSTOM1: </div> <div style="float:right;margin-right:380px"> <input type="text" id="fCustom1" name="fCustom1"> </div> </div> <br> <br> <div> <div style="float:left"> F_CUSTOM2_NAME: </div> <div style="float:right;margin-right:380px"> <input type="text" id="fCustom2Name" name="fCustom2Name"> </div> </div> <br> <br> <div> <div style="float:left"> F_CUSTOM2: </div> <div style="float:right;margin-right:380px"> <input type="text" id="fCustom2" name="fCustom2"> </div> </div> <br> <br> <div> <div style="float:left"> F_PRODUCT: </div> <div style="float:right;margin-right:380px"> <input type="text" id="fProduct" name="fProduct"> </div> </div> <br> <br> <div> <div style="float:left"> F_SERVICE: </div> <div style="float:right;margin-right:380px"> <input type="text" id="fService" name="fService"> </div> </div> </div> <br> <br> <div id="mainProceed" style="display:none" align="center"> <button type="button" style="float:left;margin-left:800px;width:80px" onclick="backFromRightDiv()">back</button> <button type="button" style="float:right;margin-right:600px" onclick="proceedToSummary()">proceed>></button> </div> </div> <div id="summaryDiv" style="display:none"> <div id="summaryTable"></div> <br> <br> <div> <button type="button" onclick="backfromSummary()">back</button> <input type="submit" value="Add"></input> </div> </div> </form> <script type="text/javascript"> function firstStepCheck(){ if(blankCheck("brandName")&& blankCheck("fAccountId")&& blankCheck("fUrl")) return true; else return false; } function blankCheck(element){ var elemValue = document.getElementById(element).value.trim(); if(elemValue==""){ alert(element+" cannot be left Empty!!"); document.getElementById(element).focus(); return false; } return true; } function firstProceed(){ if(!firstStepCheck()) return; } </script>

<basename>*.pdf