cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Andrewlu81
Helper I
Helper I

How to write script to download data to specified folder as specified name

On my company data web site, it have download button to download data as excel, but it only to same foler, and file name is random name.

If it can't be write JS script to download the data to specified folder and specified name.

Webpage.JPG

Thanks!

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"><title>
	Genernal_Tool
</title><link href="Css/Body.css" rel="stylesheet" type="text/css" />

    <script src="My97DatePicker/WdatePicker.js" type="text/javascript"></script>
    <style>
        .ui-autocomplete-loading
        {
            background: white url("images/ui-anim_basic_16x16.gif") right center no-repeat;
        }
        .style1
        {
            width: 100%;
        }
        .style2
        {
            width: 103px;
        }
    </style>
  
</head>
<script language="javascript" for="window" event="onresize">
        if (document.title=="Window is locked") lockWindow();
</script>
<script src="../sys.js" type="text/javascript"></script>
<script type="text/javascript" src="../calendar/popcalendar.js"></script>
<body>
    <form method="post" action="./Normal_Query.aspx" id="form1">
<div class="aspNetHidden">
<input type="hidden" name="__EVENTTARGET" id="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" id="__EVENTARGUMENT" value="" />
<input type="hidden" name="__LASTFOCUS" id="__LASTFOCUS" value="" />
<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" />
</div>

<script type="text/javascript">
//<![CDATA[
var theForm = document.forms['form1'];
if (!theForm) {
    theForm = document.form1;
}
function __doPostBack(eventTarget, eventArgument) {
    if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
        theForm.__EVENTTARGET.value = eventTarget;
        theForm.__EVENTARGUMENT.value = eventArgument;
        theForm.submit();
    }
}
//]]>
</script>


<div class="aspNetHidden">

	<input type="hidden" name="__VIEWSTATEGENERATOR" id="__VIEWSTATEGENERATOR" value="E4B5808A" />
	<input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" />
</div>
    <div class="topInfo">
        <div class="title_span">
            GenralTool 》》QueryTool</div>
    </div>
    <div>
        <table style="width: 100%" cellpadding="2">
            <tr>
                <td>
                    <table class="BigTableA" cellpadding="3" cellspacing="0" border="1px" bordercolor="#0077b2">
                        <tr>
                            <td class="style2">
                                QueryReport:
                            </td>
                            <td>
                                <select name="drpQuery" onchange="javascript&colon;setTimeout(&#39;__doPostBack(\&#39;drpQuery\&#39;,\&#39;\&#39;)&#39;, 0)" id="drpQuery" class="DropDownListCss" style="font-size:Large;width:800px;">
	<option selected="selected" value="128">10111|Test_SN_Query[Test_SN_Query]</option>

</select>
                                &nbsp;&nbsp;&nbsp; &nbsp;<input type="submit" name="btnOK" value="OK" id="btnOK" class="ButtonCss" style="width:60px;" />
                            &nbsp;<input type="submit" name="btnQuery" value="Query" id="btnQuery" class="ButtonCss" style="width:67px;" />
                            &nbsp;<input type="submit" name="btnDownload" value="Download" id="btnDownload" class="ButtonCss" style="width:67px;" />
                            &nbsp;<input id="chkDown" type="checkbox" name="chkDown" /><label for="chkDown">Download </label>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <table id="HolderTable" cellspacing="0" class="BigTable2" border="1px" style="border-color:#0077B2;border-collapse:collapse;">
	<tr>
		<td style="width:150px;"><span id="lblInfo0">Project(Such as:Ver/Ola):</span></td><td style="width:500px;"><input name="PartFamilyName" type="text" value="" id="PartFamilyName" style="width:500px;" /></td>
	</tr><tr>
		<td style="width:150px;"><span id="lblInfo1">Station:</span></td><td style="width:500px;"><select name="TestTypeID" id="TestTypeID" style="width:500px;">
			<option selected="selected" value="0">All</option>
		</select></td>
	</tr>
</table>
          </td>
          </tr>
          <tr>
                <td align="center" colspan="2">
                      <span id="lblMessage" AutoPostBack="True" style="display:inline-block;color:Red;height:17px;width:940px;">
                      </span>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </div>
    <table class="style1">
        <tr>
            <td>
                <div>
<table class="Admin_Table" cellspacing="0" rules="all" border="1" id="grv" style="font-family:Calibri;font-size:12px;border-collapse:collapse;">
<tr class="Admin_Table_Title" style="white-space:nowrap;">
<th scope="col">SN_LaserSN</th>
<th scope="col">UnitState</th>
<th scope="col">StationType</th>
<th scope="col">Line</th>
<th scope="col">TestTime</th>
<th scope="col">FailDescription</th>
<th scope="col">testGeneration</th>
<th scope="col">TestResult_Final</th>
</tr>
<tr>
<td>U20050020AE</td>
<td>S5_test</td>
<td>Line1</td>
<td>1/6/2022 2:41:34 PM</td>
<td>DSP Trim Result</td>
<td>1</td>
<td>Pass</td>
</tr>
</table>
</div>
            </td>
        </tr>
    </table>

    </form>
</body>
</html>

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
MichaelAnnis
Super User
Super User

If it is one file, and it's always to the same folder, the name doesn't matter.

 

'after you have downloaded the file

Get Files (under Advanced - sorted by last modified descending, so newest is on top)

Rename Files %Files[0]% to %RenamedFiles%

Move Files %RenamedFiles% to whatever folder you want. 

View solution in original post

5 REPLIES 5
MichaelAnnis
Super User
Super User

If it is one file, and it's always to the same folder, the name doesn't matter.

 

'after you have downloaded the file

Get Files (under Advanced - sorted by last modified descending, so newest is on top)

Rename Files %Files[0]% to %RenamedFiles%

Move Files %RenamedFiles% to whatever folder you want. 

Thank you! your are hearted person! it good help me!

How to fill the file filter setting in Get Files flow?

Capture.JPG

Thanks!

Just a * works for all files. If it is your downloads folder, that might be a little much. If it is an xlsx, than you could use *.xlsx to limit it to just excel files. But * is the wildcard for unknown amount of characters. 

If fill * that will move all document.

if it can only select order by Created time descending limited 1?

Helpful resources

Announcements
MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power automate tips 768x460 v2.png

Restore a Deleted Flow

Did you know that you could restore a deleted flow? Check out this helpful article.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Users online (2,263)