找回密码
 注册
搜索
[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
查看: 17700|回复: 4

[已解决]20元 bat或Powershell处理文本内容使其倒序排列

  [复制链接]
发表于 2019-5-13 13:34:17 | 显示全部楼层 |阅读模式
具体报酬:20元人民币
支付方式:支付宝,微信转账
联系方式:QQ296578353
有效期限:问题解决之前。WHY请联系一下我可以吗?转点小钱略表感谢。已经帮助我很多次了,而且每次给出的答案都是切实可行的。

情景再现自己写好的代码 被人抄袭套用 可气的是对方还在代码前加上“原创代码,抄袭举报” 真是此地无银三百两掩耳盗铃的小人
为了保护自身知识产权,需要一个把写好的代码中数组位置置换 去除写代码时的思路备注 去除换行符号(后边再用工具加密)

需要处理以下类似文本
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <Lockscreen screenWidth="1080" frameRate="45" displayDesktop="true" scale="1*#scalescreen" pivotX="#screen_width/2" pivotY="#screen_height/2" alpha="255*#homescreen_action">
  3.         <!-- Start-2019.5.12        =x=2019.5.12 -->
  4.         <Button x="0" y="0" w="#screen_width" h="#screen_height" />       
  5.         <ExternalCommands>
  6.                 <Trigger action="resume">
  7.                         <VariableCommand name="ts" expression="0" />
  8.                         <VariableCommand name="Sidebar_v" expression="0" />
  9.                         <VariableCommand name="wallpaper_mask" expression="1" />
  10.                         <VariableCommand name="slider_xy_flag" expression="0" />
  11.                         <VariableCommand name="unlocker_flag" expression="0" />
  12.                         <VariableCommand name="unlocked" expression="0" />
  13.                         <AnimationCommand target="timemove" command="play(500,1000)" delay="0" condition="eq(#timemove,0)*#blackbg" />  
  14.                         <AnimationCommand target="timemove2" command="play(500,1400)" delay="0" condition="eq(#timemove2,0)*#blackbg" />
  15.                         <AnimationCommand target="timemove3" command="play(500,1800)" delay="0" condition="eq(#timemove3,0)*#blackbg" />
  16.                         <AnimationCommand target="timemove" command="play(1000,0)" delay="0" condition="eq(#timemove,0)*not(#blackbg)" />  
  17.                         <AnimationCommand target="timemove2" command="play(1400,0)" delay="0" condition="eq(#timemove2,0)*not(#blackbg)" />
  18.                         <AnimationCommand target="timemove3" command="play(1800,0)" delay="0" condition="eq(#timemove3,0)*not(#blackbg)" />
  19.                         <AnimationCommand target="appmove" command="play(800,0)" delay="0" condition="eq(#appmove,0)*not(#blackbg)" />               
  20.                         <AnimationCommand target="appalpha" command="play(0)" delay="0" condition="eq(#appalpha,0)*not(#blackbg)" />  
  21.                         <AnimationCommand target="bzmove" command="play" />
  22.                 </Trigger>
  23.                 <Trigger action="pause">
  24.                         <VariableCommand name="Sidebar_v" expression="0" />
  25.                         <VariableCommand name="suiji_bg" expression="ifelse(not(#Img_ID),round(rand(0)*7+1),#Img_ID)" />
  26.                         <AnimationCommand target="scale_charge" command="play(200,0)" condition="eq(#charge,1)"/>
  27.                         <AnimationCommand target="chargealpha" command="play(200,0)" condition="eq(#charge,1)"/>
  28.                         <AnimationCommand target="bgalpha" command="play(1800,0)"  condition="eq(#blackbg,1)" />
  29.                 </Trigger>
  30.         </ExternalCommands>

  31.         <VariableBinders>
  32.                 <ContentProviderBinder name="data" uri="content://keyguard.notification/notifications" columns="icon,title,content,time,info,subtext,key" countName="hasnotifications">
  33.                         <Variable name="notification_icon" type="blob.bitmap" column="icon" row="0" />
  34.                         <Variable name="notification_title" type="string" column="title" row="0" />
  35.                         <Variable name="notification_content" type="string" column="content" row="0" />
  36.                         <Variable name="notification_time" type="string" column="time" row="0" />
  37.                         <Variable name="notification_info" type="string" column="info" row="0" />
  38.                         <Variable name="notification_subtext" type="string" column="subtext" row="0" />
  39.                         <Variable name="notification_key" type="int" column="key" row="0" />
  40.                         <List name="notification_list" />
  41.                 </ContentProviderBinder>
  42.                 <SensorBinder type="gravity" rate="60">
  43.                         <Variable name="gravity_x" index="0" />
  44.                         <Variable name="gravity_y" index="1" />
  45.                         <Variable name="gravity_z" index="2" />
  46.                 </SensorBinder>
  47.                 <SensorBinder type="linear_acceleration">
  48.                         <Variable name="linear_acceleration_x" index="0" />
  49.                         <Variable name="linear_acceleration_y" index="1" />
  50.                         <Variable name="linear_acceleration_z" index="2" />
  51.                 </SensorBinder>
  52.                 <SensorBinder type="linear_acceleration" rate="2">
  53.                         <Variable name="va_x" index="0" />
  54.                         <Variable name="va_y" index="1" />
  55.                         <Variable name="va_z" index="2" />
  56.                 </SensorBinder>
  57.         </VariableBinders>

  58.         <!-- 公交卡-->
  59.         <Group visibility="#nfc" >                
  60.                 <Var name="shuaidong_judge" expression="#linear_acceleration_x" threshold="8">
  61.                         <Trigger>
  62.                                 <VariableCommand name="shuaidong_num" expression="#shuaidong_num+1" />
  63.                         </Trigger>
  64.                 </Var>
  65.                 <Var name="shuaidong_num_judge" expression="#shuaidong_num" threshold="3">
  66.                         <Trigger>
  67.                                 <IntentCommand action="com.miui.intent.action.DOUBLE_CLICK" package="com.miui.tsmclient">
  68.                                         <Extra name="event_source" type="string" expression="'key_volume_down'" />
  69.                                 </IntentCommand>
  70.                         </Trigger>
  71.                 </Var>
  72.         </Group>
  73. </Lockscreen>
复制代码
1.删除<!--和-->之间内容包含<!---->
2.每行中数组降序
如<Text x="10" y="90" size="35" color="#ffffff" textExp="'cbl_ani: '+#cbl_ani"/>变为<Text textExp="'cbl_ani: '+#cbl_ani"  color="#ffffff" size="35" y="90" x="10"/>
如<Button x="0" y="0" w="#screen_width" h="#screen_height"/>变为<Button h="#screen_height" w="#screen_width "y="0" x="0"/>
3.去除段前段后空行 去除换行符 使其变成一行
发表于 2019-5-14 11:49:27 | 显示全部楼层
本帖最后由 WHY 于 2019-5-21 09:39 编辑

test.ps1
  1. $str = [IO.File]::ReadAllText('a.txt', [Text.Encoding]::Default);
  2. $str = $str -replace '(?m)^\s+|\s*(?:\n|$)' -replace '<!--(?:(?!-->).)*-->';
  3. $str = [regex]::Replace($str, '(?<=<[^<>\s]+)\s+[^<>]+"(?=\s*/?>)', {param($m); [Collections.ArrayList]$a=$m.Value -split '(?<=="[^"]*")';$a.Reverse();$a -join ''});
  4. [IO.File]::WriteAllText('b.txt', $str, [Text.Encoding]::UTF8);
复制代码
如果要保存为Test.BAT
(1) 对ps脚本块而言,双引号用反斜杠转义;
(2) 对bat脚本而言,暴露在 "双引号对" 之外的特殊字符用^转义。
  1. @echo off
  2. PowerShell "$s = [IO.File]::ReadAllText('a.txt', [Text.Encoding]::Default) -replace '(?m)^\s+|\s*(?:\n|$)' -replace '<!--(?:(?!-->).)*-->';$s = [regex]::Replace($s, '(?<=<[^<>\s]+)\s+[^<>]+"(?=\s*/?^>)',{param($m);[Collections.ArrayList]$a=$m.Value -split '(?^<=="[^"]*")';$a.Reverse();$a -join ''});sc b.txt -Value $s -Enc UTF8"
  3. pause
复制代码

评分

参与人数 1技术 +1 收起 理由
smss + 1 就服你

查看全部评分

 楼主| 发表于 2019-5-14 13:37:17 | 显示全部楼层
回复 2# WHY 我可以知道你的联系方式吗?你已经帮助我很多次了。
发表于 2019-5-14 21:19:09 | 显示全部楼层
回复 3# smss


    好,站内短信发给你了。
 楼主| 发表于 2019-5-15 20:51:38 | 显示全部楼层
本帖最后由 smss 于 2019-5-20 21:16 编辑

回复 4# WHY
我把这个保存为好 用BAT调用
  1. @echo off
  2. powershell.exe -command "&{%~dp0test.ps1}"
复制代码
除了上边这种,可以类似以下这样写吗
  1. PowerShell "[Collections.ArrayList]$arr=[IO.File]::ReadAllLines('1.txt') -replace '^20|(?<!\d\d)\s';$arr.Reverse();sc 2.txt -Value $arr"
复制代码
  1. PowerShell "$str=[IO.File]::ReadAllText('manifest.xml', [Text.Encoding]::Default);$str=$str -replace '(?m)^\s+|\s*(?:\n|$)' -replace '<!--(?:(?!-->).)*-->';[IO.File]::WriteAllText('manifest1.xml', $str, [Text.Encoding]::UTF8)"
复制代码
只加成功半句 难受
  1. PowerShell "$str=[IO.File]::ReadAllText('manifest.xml', [Text.Encoding]::Default);$str=$str -replace '(?m)^\s+|\s*(?:\n|$)' -replace '<!--(?:(?!-->).)*-->';$str=[regex]::Replace($str, '(?<=<[^<>\s]+)\s+[^<>]+"(?=\s*/?>)', {param($m); [Collections.ArrayList]$a=$m.Value -split '(?<=="[^"]*")';$a.Reverse();$a -join ''});[IO.File]::WriteAllText('manifest1.xml', $str, [Text.Encoding]::UTF8)"
  2. 最后一句不知道错在哪
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|批处理之家 ( 渝ICP备10000708号 )

GMT+8, 2026-3-17 04:11 , Processed in 0.019971 second(s), 9 queries , File On.

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表